Kære gæst, velkommen til Tweak.dk. Hvis dette er dit første besøg her, bør du læse Hjælp. Her forklares i detaljer hvordan denne side fungerer. For at benytte alle funktionerne på denne side, bør du overveje at lade dig registrere. Benyt venligst registreringsformularen for at registrere her eller læs yderligere information om registreringsprocessen. Hvis du allerede er registreret, så log på her.

1

onsdag, 23. april 2008, 20:25


Hvad kan jeg have gjort forkert her??

Kildekode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

$uploadDir = 'uploads/'; //Bibliotek hvor filer uploades til - husk chmod 777
$allowedFileTypes = array('jpg','gif','png'); 
//Hvilke filer vil vi acceptere bliver uploadet?
//Er der trykket på Upload file knappen?

if(isset($_POST['myUpload'])){  
//Har vi en fil?  

if(is_uploaded_file($_FILES['myFile']['tmp_name']))  
{    
//Filendelse    
$extension = pathinfo($_FILES['myFile']['name'],PATHINFO_EXTENSION); 
//Er filen en af de filer vi gerne vil have?    
if(in_array($extension,$allowedFileTypes))    
{      
//Vi flytter filen fra tmp til vores UPLOADDIR      
if(move_uploaded_file($_FILES['myFile']['tmp_name'],$uploadDir . basename($_FILES['myFile']['name'])))
  {        
	  echo '<h3 style="color:green;">File ('.basename($_FILES['myFile']['name']).') uploaded succesfully</h3>';
		}     
		else      
		{        
	
	  echo '<h3 style="color:red;">Error - unable to upload file: '.basename($_FILES['myFile']['name']).'</h3>';      

		}    
		else    
		{   
		
		echo '<h3 style="color:red;">Wrong filetype, allowed filetypes are: ('.implode(',',$allowedFileTypes).')</h3>';
		}  
	
		}  	 
		else  
		{    
		echo '<h3 style="color:red;">No file selected</h3>';  
	}
}
//Vores formecho 
echo'<form action="upload.php" method="post" enctype="multipart/form-data">';
echo'File ('.implode(',',$allowedFileTypes).'):<input type="file" name="myFile"><br />';
echo '<input type="submit" name="myUpload" value="Upload file">';
echo '</form>';

?>


2

onsdag, 23. april 2008, 20:54


Hvad er fejlen?

Intel i5-4690K @ 4,7ghz
Coolmaster EVO212
ASUS Z97-A
Crucial Ballistix Sport 2x4GB
Crucial MX100 240GB SSD
Gigabyte 970 G1 4GB
Fractal Design Arc Midi R2

3

onsdag, 23. april 2008, 21:02


Det virkede bare ikke hos mig, men nu har jeg funet ud af at min host ikke tillader det, havde ellers spurgt online support, som gav mig et andet svar men de tillader det altså ikke.... møg

Hmm.... :boxed: hvordan kan man så fikse noget med billeder, hvis det er til en kunde som ikke kan finde ud af et ftp program.


4

onsdag, 23. april 2008, 21:05


Citeret

Oprindeligt indlæg af dmy
Det virkede bare ikke hos mig, men nu har jeg funet ud af at min host ikke tillader det, havde ellers spurgt online support, som gav mig et andet svar men de tillader det altså ikke.... møg

Hmm.... :boxed: hvordan kan man så fikse noget med billeder, hvis det er til en kunde som ikke kan finde ud af et ftp program.


Så må din host da svare dig på hvad det er de ikke understøtter? Hvilke host?

Intel i5-4690K @ 4,7ghz
Coolmaster EVO212
ASUS Z97-A
Crucial Ballistix Sport 2x4GB
Crucial MX100 240GB SSD
Gigabyte 970 G1 4GB
Fractal Design Arc Midi R2

5

onsdag, 23. april 2008, 21:17


det er one.com


6

onsdag, 23. april 2008, 21:25


Der har jeg ellers 2 kunder med upload script.

Intel i5-4690K @ 4,7ghz
Coolmaster EVO212
ASUS Z97-A
Crucial Ballistix Sport 2x4GB
Crucial MX100 240GB SSD
Gigabyte 970 G1 4GB
Fractal Design Arc Midi R2

7

onsdag, 23. april 2008, 21:27


så forstår jeg ikke hvad det er der er galt..... :boxed:
Det har drillet helt vildt, alle scripts jeg har prøvet.


8

onsdag, 23. april 2008, 21:33


Prøv den her :) Orker ikke lige at tjekke din kode igennem.
http://www.phphq.net/scripts.php?p=free-scripts&id=1

Intel i5-4690K @ 4,7ghz
Coolmaster EVO212
ASUS Z97-A
Crucial Ballistix Sport 2x4GB
Crucial MX100 240GB SSD
Gigabyte 970 G1 4GB
Fractal Design Arc Midi R2

9

onsdag, 23. april 2008, 21:57


Der mangler en afsluttende } på linje 29.
Ellers bør det virke 100% så længe chmod er sat til 777 op uploads mappen

PHP kildekode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

$uploadDir 'uploads/'//Bibliotek hvor filer uploades til - husk chmod 777
$allowedFileTypes = array('jpg','gif','png'); 
//Hvilke filer vil vi acceptere bliver uploadet?
//Er der trykket på Upload file knappen?

if(isset($_POST['myUpload'])){  
//Har vi en fil?  

if(is_uploaded_file($_FILES['myFile']['tmp_name']))  
{    
//Filendelse    
$extension pathinfo($_FILES['myFile']['name'],PATHINFO_EXTENSION); 
//Er filen en af de filer vi gerne vil have?    
if(in_array($extension,$allowedFileTypes))    
{      
//Vi flytter filen fra tmp til vores UPLOADDIR      
if(move_uploaded_file($_FILES['myFile']['tmp_name'],$uploadDir basename($_FILES['myFile']['name'])))  {        
      echo '<h3 style="color:green;">File ('.basename($_FILES['myFile']['name']).') uploaded succesfully</h3>';
        }     
    else      {        
    
     echo '<h3 style="color:red;">Error - unable to upload file: '.basename($_FILES['myFile']['name']).'</h3>';      

    }    
        }
        else    
        {   
        
        echo '<h3 style="color:red;">Wrong filetype, allowed filetypes are: ('.implode(',',$allowedFileTypes).')</h3>';
        }  
    
        }       
        else  
        {    
        echo '<h3 style="color:red;">No file selected</h3>';  
    }
}
//Vores formecho 
echo'<form action="upload.php" method="post" enctype="multipart/form-data">';
echo'File ('.implode(',',$allowedFileTypes).'):<input type="file" name="myFile"><br />';
echo '<input type="submit" name="myUpload" value="Upload file">';
echo '</form>';

?>


10

torsdag, 24. april 2008, 10:17


Takker for det begge to, jeg hentede det er der blev linket til og det virker, tak for det ;)


11

torsdag, 24. april 2008, 17:36


Hvis nu jeg skal lave noget resize på billederne inden de bliver uploadet hvordan gør jeg det hvor kan man sætte det ind i koden og hvad skal jeg sætte ind.

Kildekode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?
error_reporting(7);


// Max size PER file in KB, not bytes for simplicity!
$max_file_size="1024";

// Max size for all files COMBINED in KB, not bytes for simplicity!
$max_combined_size="2048";

//How many file uploads do you want to allow at a time?
$file_uploads="2";

//The name of the uploader..
$websitename="phUploader 1.2";

// Use random file names? true=yes (recommended), false=use original file name. Random names will help prevent overwritting of existing files!
$random_name=true;

// Please keep the array structure.
$allow_types=array("jpg","gif","png","zip","rar","txt","doc");

// Path to files folder. If this fails use $fullpath below. With trailing slash
$folder="./uploads/";

// Full url to where files are stored. With Trailing Slash
$full_url="http://www.ditdomæne.dk/uploads/";

// Only use this variable if you wish to use full server paths. Otherwise leave this empty! With trailing slash
$fullpath="";

//Use this only if you want to password protect your uploads.
$password=""; 



// MD5 the password.. why not?
$password_md5=md5($password);

// If you set a password this is how they get verified!
If($password) {
	If($_POST['verify_password']==true) {
		If(md5($_POST['check_password'])==$password_md5) {
			setcookie("phUploader",$password_md5,time()+86400);
			sleep(1); //seems to help some people.
			header("Location: [URL]http://[/URL]".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
			exit;
			
		}
	}
}

// The password form, if you set a password and the user has not entered it this will show.
$password_form="";
If($password) {
	If($_COOKIE['phUploader']!=$password_md5) {
		$password_form="<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">\n";
		$password_form.="<table align=\"center\" class=\"table\">\n";
		$password_form.="<tr>\n";
		$password_form.="<td width=\"100%\" class=\"table_header\" colspan=\"2\">Password Required</td>\n";
		$password_form.="</tr>\n";
		$password_form.="<tr>\n";
		$password_form.="<td width=\"35%\" class=\"table_body\">Enter Password:</td>\n";
		$password_form.="<td width=\"65%\" class=\"table_body\"><input type=\"password\" name=\"check_password\" /></td>\n";
		$password_form.="</tr>\n";
		$password_form.="<td colspan=\"2\" align=\"center\" class=\"table_body\">\n";
		$password_form.="<input type=\"hidden\" name=\"verify_password\" value=\"true\">\n";
		$password_form.="<input type=\"submit\" value=\" Verify Password \" />\n";
		$password_form.="</td>\n";
		$password_form.="</tr>\n";
		$password_form.="</table>\n";
		$password_form.="</form>\n";
	}
}

// Function to get the extension a file.
function get_ext($key) { 
	$key=strtolower(substr(strrchr($key, "."), 1));
	// Cause there the same right?
	$key=str_replace("jpeg","jpg",$key);
	return $key;
}

$ext_count=count($allow_types);
$i=0;
foreach($allow_types AS $extension) {
	
	//Gets rid of the last comma for display purpose..
	
	If($i <= $ext_count-2) {
		$types .="*.".$extension.", ";
	} Else {
		$types .="*.".$extension;
	}
	$i++;
}
unset($i,$ext_count); // why not

$error="";
$display_message="";
$uploaded==false;

// Dont allow post if $password_form has been populated
If($_POST['submit']==true AND !$password_form) {

	For($i=0; $i <= $file_uploads-1; $i++) {
					
		If($_FILES['file']['name'][$i]) {
						
			$ext=get_ext($_FILES['file']['name'][$i]);
			$size=$_FILES['file']['size'][$i];
			$max_bytes=$max_file_size*1024;
			
			// For random names
			If($random_name){
				$file_name[$i]=time()+rand(0,100000).".".$ext;
			} Else {
				$file_name[$i]=$_FILES['file']['name'][$i];
			}
			
			//Check if the file type uploaded is a valid file type. 
						
			If(!in_array($ext, $allow_types)) {
							
				$error.= "Invalid extension for your file: ".$_FILES['file']['name'][$i].", only ".$types." are allowed.<br />Your file(s) were <b>not</b> uploaded.<br />";
							
				//Check the size of each file
							
			} Elseif($size > $max_bytes) {
				
				$error.= "Your file: ".$_FILES['file']['name'][$i]." is to big. Max file size is ".$max_file_size."kb.<br />Your file(s) were <b>not</b> uploaded.<br />";
				
				// Check if the file already exists on the server..
			} Elseif(file_exists($folder.$file_name[$i])) {
				
				$error.= "The file: ".$_FILES['file']['name'][$i]." exists on this server, please rename your file.<br />Your file(s) were <b>not</b> uploaded.<br />";
				
			}
						
		} // If Files
	
	} // For
	
	//Tally the size of all the files uploaded, check if it's over the ammount.
				
	$total_size=array_sum($_FILES['file']['size']);
	  			
	$max_combined_bytes=$max_combined_size*1024;
				
	If($total_size > $max_combined_bytes) {
		$error.="The max size allowed for all your files combined is ".$max_combined_size."kb<br />";
	}
		
	
	// If there was an error take notes here!
	
	If($error) {
		
		$display_message=$error;
		
	} Else {
		
		// No errors so lets do some uploading!
		
		For($i=0; $i <= $file_uploads-1; $i++) {
				
			If($_FILES['file']['name'][$i]) {
				
				If(@move_uploaded_file($_FILES['file']['tmp_name'][$i],$folder.$file_name[$i])) {
					$uploaded=true;
				} Else {
					$display_message.="Couldn't copy ".$file_name[$i]." to server, please make sure ".$folder." is chmod 777 and the path is correct.\n";
				}
			}
				
		} //For
		
	} // Else
	
} // $_POST AND !$password_form

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $websitename; ?> - Powered By phUploader</title>

<style type="text/css">
	body{
		background-color:#FFFFFF;
		font-family: Verdana, Arial, sans-serif;
		font-size: 12pt;
		color: #000000;
	}
	
	.error_message{
		font-family: Verdana, Arial, sans-serif;
		font-size: 11pt;
		color: #FF0000;
	}
	
	.uploaded_message{
		font-family: Verdana, Arial, sans-serif;
		font-size: 11pt;
		color: #000000;
	}
	
	a:link{
		text-decoration:none;
		color: #000000;
	}
	a:visited{
		text-decoration:none;
		color: #000000;
	}
	a:hover{
		text-decoration:none;
		color: #000000;
	}
	
	
	.table {
		border-collapse:collapse;
		border:1px solid #000000;
		width:450px;
	}
	
	.table_header{
		border:1px solid #070707;
		background-color:#aaaaaa;
		font-family: Verdana, Arial, sans-serif;
		font-size: 11pt;
		font-weight:bold;
		color: #FFFFFF;
		text-align:center;
		padding:2px;
	}
	
	.upload_info{
		border:1px solid #070707;
		background-color:#EBEBEB;
		font-family: Verdana, Arial, sans-serif;
		font-size: 8pt;
		color: #000000;
		padding:4px;
	}
	
	
	.table_body{
		border:1px solid #070707;
		background-color:#EBEBEB;
		font-family: Verdana, Arial, sans-serif;
		font-size: 10pt;
		color: #000000;
		padding:2px;
	}
	
	
	.table_footer{
		border:1px solid #070707;
		background-color:#aaaaaa;
		text-align:center;
		padding:2px;
	}
	
	
	input,select,textarea {
		font-family: Verdana, Arial, sans-serif;
		font-size: 10pt;
		color: #000000;
		background-color:#AFAEAE;
		border:1px solid #000000;
	}
	
	.copyright {
		border:0px;
		font-family: Verdana, Arial, sans-serif;
		font-size: 9pt;
		color: #000000;
		text-align:right;
	}
	
	form{
		padding:0px;
		margin:0px;
	}
</style>

<?
If($password_form) {
	
	Echo $password_form;
	
} Elseif($uploaded==true) {?>

<table align="center"class="table">

	<tr>
		<td class="table_header" colspan="2"><b>Your file(s) have been uploaded!</b> </td>
	</tr>
	<tr>
	<td class="table_body">
	<br />
<?
For($i=0; $i <= $file_uploads-1; $i++) {
	
	If($_FILES['file']['name'][$i]) {
		$file=$i+1;
		
				Echo("<b>File #".$file.":</b> <a href=\"".$full_url.$file_name[$i]."\" target=\"_blank\">".$full_url.$file_name[$i]."</a><br /><br />\n");
	}
				
}

?>
<br />
<a href="<?=$_SERVER['PHP_SELF'];?>">Go Back</a>
<br />
</td>
</tr>
</table>

<?} Else {?>

<?If($display_message){?>
	<div align="center" class="error_message"><?=$display_message;?></div>
	<br />
<?}?>

<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="phuploader">
<table align="center"class="table">

	<tr>
		<td class="table_header" colspan="2"><b><?=$websitename;?></b> </td>
	</tr>
	<tr>
		<td colspan="2" class="upload_info">
			<b>Allowed Types:</b> <?=$types?><br />
			<b>Max size per file:</b> <?=$max_file_size?>kb.<br />
			<b>Max size for all files combined:</b> <?=$max_combined_size?>kb.<br />
		</td>
	</tr>
	<?For($i=0;$i <= $file_uploads-1;$i++) {?>
		<tr>
			<td class="table_body" width="20%"><b>Select File:</b> </td>
			<td class="table_body" width="80%"><input type="file" name="file[]" size="30" /></td>
		</tr>
	<?}?>
	<tr>
		<td colspan="2" align="center" class="table_footer">
			<input type="hidden" name="submit" value="true" />
			<input type="submit" value=" Upload File(s) " /> &nbsp;
			<input type="reset" name="reset" value=" Reset Form " />
		</td>
	</tr>
</table>
</form>

<?

}

</body>
</html>


Nyeste Videoer og Trailers

Indsend nyhed
Har du fundet en fed nyhed så indsend den så alle andre på Tweak.dk kan få glæde af den.