Multiple upload form
Robin
04/02/2009 13:32:00Ik heb een scriptje gevonden die perfect werkt, maar de files worden in dezelfde map gezet als waar het scriptje staat en dat wil ik niet. Ik zie niet onmiddellijk waar ik het zou kunnen aanpassen. help? :)
FORM:
FORM:
Code (php)
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
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
<?php
<form name="form1" enctype="multipart/form-data" method="post" action="uploadFiles.php">
<p>
$uploadsNeeded = 10;
for($i=0; $i < $uploadsNeeded; $i++){
<input name="uploadFile<? echo $i;" type="file" id="uploadFile<? echo $i;" />
</p>
}
<p><input name="uploadsNeeded" type="hidden" value=" echo $uploadsNeeded;" />
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
?>
Uploadfiles:
<?
$uploadsNeeded = $_POST['uploadsNeeded'];
for($i = 0; $i < $uploadsNeeded; $i++){
$file_name = $_FILES['uploadFile'. $i]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $i]['tmp_name'],$file_name);
// prompt if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
}
?>
<form name="form1" enctype="multipart/form-data" method="post" action="uploadFiles.php">
<p>
$uploadsNeeded = 10;
for($i=0; $i < $uploadsNeeded; $i++){
<input name="uploadFile<? echo $i;" type="file" id="uploadFile<? echo $i;" />
</p>
}
<p><input name="uploadsNeeded" type="hidden" value=" echo $uploadsNeeded;" />
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
?>
Uploadfiles:
<?
$uploadsNeeded = $_POST['uploadsNeeded'];
for($i = 0; $i < $uploadsNeeded; $i++){
$file_name = $_FILES['uploadFile'. $i]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $i]['tmp_name'],$file_name);
// prompt if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Robin
PHP hulp
28/12/2024 11:02:06- SanThe -
04/02/2009 13:37:00$copy = copy($_FILES['uploadFile'. $i]['tmp_name'],'hier de map waarin die moet komen' . $file_name);
En waarom copy()? Gebruik move_uploaded_file().
En waarom copy()? Gebruik move_uploaded_file().
Gewijzigd op 01/01/1970 01:00:00 door - SanThe -