Hello,
I’m putting together a small application for someone, where the user inputs their order information, and may upload up to 5 files, in which get placed in a directory on their web host.
For the most part, it’s working, except it seems to only upload the first file, but won’t upload the rest of them.
Below is the processing code.
<?
//File Upload...
//**************************************************
//Сheck that we have a file
if((!empty($_FILES["file1"])) ||
(!empty($_FILES["file2"])) ||
(!empty($_FILES["file3"])) ||
(!empty($_FILES["file4"])) ||
(!empty($_FILES["file5"])) &&
($_FILES['file1']['error'] == 0) ||
($_FILES['file2']['error'] == 0) ||
($_FILES['file3']['error'] == 0) ||
($_FILES['file4']['error'] == 0) ||
($_FILES['file5']['error'] == 0)) {
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES['file1']['name']);
$filename2 = basename($_FILES['file2']['name']);
$filename3 = basename($_FILES['file3']['name']);
$filename4 = basename($_FILES['file4']['name']);
$filename5 = basename($_FILES['file5']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$ext2 = substr($filename2, strrpos($filename2, '.') + 1);
$ext3 = substr($filename3, strrpos($filename3, '.') + 1);
$ext4 = substr($filename4, strrpos($filename4, '.') + 1);
$ext5 = substr($filename5, strrpos($filename5, '.') + 1);
if (($ext || $ext2 || ext3 || ext4 || ext5 == "jpg") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "indd") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "ai") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "eps") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "psd") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "pdf") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "tif") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "doc") ||
($ext || $ext2 || ext3 || ext4 || ext5== "docx") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "pub") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "cdr") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "xls") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "zip") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "rar") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "tar") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "sit") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "ttf") ||
($ext || $ext2 || ext3 || ext4 || ext5 == "fnt")) {
//Determine the path to which we want to save this file
$newname = dirname(__FILE__).'/orders/'.$filename;
$newname2 = dirname(__FILE__).'/orders/'.$filename2;
$newname3 = dirname(__FILE__).'/orders/'.$filename3;
$newname4 = dirname(__FILE__).'/orders/'.$filename4;
$newname5 = dirname(__FILE__).'/orders/'.$filename5;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname) || !file_exists($newname2) || !file_exists($newname3) || !file_exists($newname4) || !file_exists($newname5)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['file1']['tmp_name'],$newname)) &&
(move_uploaded_file($_FILES['file2']['tmp_name2'],$newname2)) &&
(move_uploaded_file($_FILES['file3']['tmp_name3'],$newname3)) &&
(move_uploaded_file($_FILES['file4']['tmp_name4'],$newname4)) &&
(move_uploaded_file($_FILES['file5']['tmp_name5'],$newname5))) {
//Send out Email Message
// Send out e-mail...
//**************************************************
$subject = "New Order Form";
$to = "peter@beitelligent.com";
$jobname = Trim(stripslashes($_POST['jobname']));
$contactname = Trim(stripslashes($_POST['contactname']));
$email = Trim(stripslashes($_POST['email']));
$company = Trim(stripslashes($_POST['company']));
$address = Trim(stripslashes($_POST['address']));
$phonenumber = Trim(stripslashes($_POST['phonenumber']));
$platform = Trim(stripslashes($_POST['platform']));
$service = Trim(stripslashes($_POST['service']));
$quantity = Trim(stripslashes($_POST['quantity']));
$type = Trim(stripslashes($_POST['type']));
$size = Trim(stripslashes($_POST['size']));
$colour = Trim(stripslashes($_POST['colour']));
$choose = Trim(stripslashes($_POST['choose']));
$binding = Trim(stripslashes($_POST['binding']));
$other1 = Trim(stripslashes($_POST['other1']));
$other2 = Trim(stripslashes($_POST['other2']));
$message = "Job Name:\
" . $jobname .
"\
\
Contact Name:\
" . $contactname .
"\
\
Email:\
" . $email .
"\
\
Company:\
" . $company .
"\
\
Address:\
" . $address .
"\
\
Phone Number:\
" . $phonenumber .
"\
\
Platform:\
" . $platform .
"\
\
Software Used:\
" . $service .
"\
\
Quantity:\
" . $quantity .
"\
\
Type of Paper/Stock:\
" . $type .
"\
\
Paper Size:\
" . $size .
"\
\
Print Colour:\
" . $colour .
"\
\
Please choose:\
" . $choose .
"\
\
Binding:\
" . $binding .
"\
\
Other Services:\
" . $other1 .
"\
\
Other Details:\
" . $other2 .
"\
\
File 1 Uploaded:\
" . $newname .
"\
\
File 2 Uploaded:\
" . $newname2 .
"\
\
File 3 Uploaded:\
" . $newname3 .
"\
\
File 4 Uploaded:\
" . $newname4 .
"\
\
File 5 Uploaded:\
" . $newname5 . " ";
mail($to, $subject, $message);
include('msg.php');
}
else {
echo "Error: A problem occurred during file upload! Please submit your order <a href='mailto:bradfordprint@bellnet.ca'>manually</a>";
}
} else {
echo "Error: One of the file names already exist. Please rename it and try again.";
}
} else {
echo "Error. Your file does meet the requirements. Please check the file and try again.";
}
} else {
echo "Error: No file uploaded";
}
?>
Although, it displays what the files are in the email, it doesn’t seem to upload them…
Any ideas?