Forum Moderators: coopster

Message Too Old, No Replies

multiple file upload success statement

confirmation screen

         

soapystar

10:04 am on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



with regards to this code:
[webmasterworld.com...]

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.

coopster

2:07 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Just set the variable within the loop.
while (looping) { 
if (successful upload AND !isset($success)) $success = 'UPLOAD SUCCESSFUL!';
}

soapystar

2:26 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks but can't get that to work either. Where would it be inserted in this code?

<?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...");
}


}

?>

Warboss Alex

3:19 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



Would it need to be inserted? If the upload fails, you've set the script to die().

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..