-
Uploading Multiple Files
Hi.. I found this script that allows you to upload multiple files. It only displays one upload form at a time, and thanks to javascript, starts a list of all the files you selected. THIS works fine... The only drawback to this cool script is that it formats the $_FILES data by naming each upload differently (the name property in the HTML file input is fixed for every upload box as "file_0", "file_1", "file_2" and so on...), instead of using the same name, and indexing the multiple files. Since I dont want to go through the other authors JavaScript, i've been trying to write my php to adjust accordingly.. What I have works just fine. It creates the customer's directory just fine, however it doesn't put anything inside of it, but it doesn't give me any errors on the move_uploaded_file, and it shows the files array in full when I print_r($_FILES)... what's going on here???
Heres my code:
$numFiles = $_GET['numFiles'];
$orderId = $vars['orderID'];
$destDir = "uploads/".$orderId;
mkdir($destDir, 0777);
for ($i=0; i<$numFiles; $i++) {
$file = "file_".$i;
$name = basename($_FILES[$file]['name']);
$location = $destDir.'/'.$name;
if (move_uploaded_file($_FILES[$file]['tmp_name'], $location)){
@chmod($location, 0775);
} else { die('Upload Failed. '.mysql_error());}
}
@chmod($destDir, 0775) or die('Error on chmod....');
#REST OF CODE...
-
-
nevermind, got it...
missing a $ infront of the i....
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks