Forum Moderators: coopster
i can't work out how to have a single statment of UPLOAD WAS SUCCESSFUL no matter how many uploads were made at one go. My form has 5 file upload fields. Any advice gratfully recieved.
<?php
global $userfile,$userfile_name,$userfile_size;
$max_files=5; //specify the no. of files uploaded
$dir = '/home/user/public_html/upload_file/';
//location of the directory on the server where
//you want to upload the files
//Here is the loop
for ($i=0;$i<$max_files;$i++)
{
if ($userfile_size[$i] > 0)
{
$filename[$i] = basename($userfile_name[$i]);
$target="$dir/".$filename[$i];
if(!@copy($userfile[$i],$target))
die("Error: A problem occured while uploading $filename[$i]. Aborting...");
}
}
?>
Just add an echo statement after the for loop. If the script hasn't died, it would output success ..
If you want a success for each upload, you'd have to remove the die statement, because if the first upload failed, the others wouldn't be verified either.
Just some thoughts..