Multiple File Upload not working, HELP!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EverToDesign
Forum Newbie
Posts: 10
Joined: Sat Oct 11, 2003 9:38 am

Multiple File Upload not working, HELP!

Post by EverToDesign »

Hey guys, heres the deal i have 2 pages. admin and admin2.php

Admin.php has a simple form (http://www.everto.net/sexvids/admin.php)

it has 9 upload boxes and comment boxes. Right now im working on the images, each upload box is named userfile[1], userfile[2], userfile[3] etc all the way up to userfile[9]. The form when submitted goes to admin2.php

Here it should loop until it uploads each file, instead the script seems to die and i get a blank screen.
Below is the PHP Source for admin2.php

Any ideas on whats wrong?

$archive_dir = "/images";
for ($counter=1; $counter<10; $counter++)
{
if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile[$counter]);

$filename = basename($userfile[$counter]_name);

if($userfile_size[$counter] <= 0) die ("$filename is empty.");

if(!@copy($userfile[$counter], "$archive_dir/$filename"))
die("Can't copy $userfile_name to $filename.");

echo "$filename has been successfully uploaded to images/$filename.<BR>";
echo "Filesize: " . number_format($userfile_size) . "<BR>";
echo "Filetype: $userfile_type<BR>";
echo "A List of All Files is at dddd";

}
echo "all done";
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Could you take off the '@' symbol before the 'copy' function, and see if that produces an error?

Also, you need the full path to the upload directory, not just "/images/folder/". You need something like "/usr/account/www/images/folder/"
Image Image
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I'm not sure where you're getting $userfile from? When you upload the files you should get:
$_FILES['userfile'][1];
$_FILES['userfile'][2];
etc..etc..
Do a print_r($_FILES); to confirm this.

So wherever you have $userfile i would use $_FILES['userfile']

Also
$filename = basename($userfile[$counter]_name);
That can't be right. Maybe you want
$filename = basename($_FILES['userfile'][$counter]['name']);
?
Post Reply