I written a form that email me the txt fields than it supposed to upload each attachment to a dir that create from the $_REQUEST["BusinessName"]
I can't edit the php.ini so I can upload up to 2.5MB
T triad to upload one by one but I get
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Can someone help me
This is the script
Thanks
GIL
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
$to = "my-email@my-site.com" ;
$from = $_REQUEST["BusinessName"] ;
$name = $_REQUEST["Legal_Name"];
$headers = "From: $from";
$subject = "Web Contact Data";
// create DIR in server with the name of the Business
$DIR= $from;
mkdir($DIR,0755);
// get all the fields together
hebrevc ($fields = array());
hebrevc ($fields{"BusinessName"} = "BusinessName");
hebrevc ($fields{"ENBusinessName"} = "ENBusinessName");
hebrevc ($fields{"BusinessPhone"} = "BusinessPhone");
hebrevc ($fields{"BusinessAddress"} = "BusinessAddress");
hebrevc ($fields{"area"} = "area");
hebrevc ($fields{"email"} = "email");
hebrevc ($fields{"internet"} = "internet");
hebrevc ($fields{"radiobutton"} = "radiobutton");
hebrevc ($fields{"stars"} = "stars");
hebrevc ($fields{"Legal_Name"} = "Legal_Name");
hebrevc ($fields{"Legal_Phone"} = "Legal_Phone");
hebrevc ($fields{"legal_e-mail"} = "legal_e-mail");
hebrevc ($fields{"description"} = "description");
$body = "We have received the following information:\n\n";
foreach($fields as $a => $b){ $body = sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
hebrevc ($send = mail($to, $subject, $body, $headers));
if($sent)
{print "We encountered an error sending your mail <br>"; }
else
{
// ----------> upload all images to BusinessName dir that created in the server
$target = $DIR;
// ------------------------ <<<<doing the first attachment >>>>>----------------
// check if there is a logo ===>
if($_FILES['logo']['name']=='')
{
$checkLogo = 0; // thare is no logo
$checkLeft = 1; // go to check if there is a left image
}
else
{
$checkLogo = 1; // thare is a logo
}
// --------------> uploading logo
if ($checkLogo ==1)
{
$target = $target . basename( $_FILES['logo']['name']) ;
$logo=1;
//This is our size condition
if ($uploaded_size > 2050000)
{
echo "Your file is too large.<br>";
$logo=0;
}
//Allowable file ext. names. you may add more extension names.
$file_name = $_FILES['logo']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$FILE_EXTS = array('.jpg','.png','.gif','.bmp','.jpeg','.tiff','.tif','.jpe','.pdf');
//Allow file delete? no, if only allow upload only
$DELETABLE = false;
if (!in_array($file_ext, $FILE_EXTS) )
{
echo "הקובץ המצורף כלוגו אינו תמונה לכן לא נשלח <br>";
$logo=0;
$checkLeft = 1;
}
//Here we check that $logo was not set to 0 by an error
if ($logo==0)
{
Echo "ישנה בעיה עם שליחת תמונת הלוגו, עליך לשלוחה במייל לכתובת <br>";
$checkLeft = 1;
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['logo']['tmp_name'], $target))
{
echo "הקובץ בשם ". basename( $_FILES['uploadedfile']['name']). " נשלח בהצלחה <br> <br>";
sleep(2) // wait for 2 sec befor start the next upload
$checkLeft = 1;
}
else
{
echo "ישנה בעיה עם שליחת תמונת הלוגו, עליך לשלוחה במייל לכתובת<br>";
$checkLeft = 1;
}
}
}
// ------------------------ <<<<do the second loop >>>>>----------------
// check if there is a left ===>
if($_FILES['left']['name']=='')
{
$checkleft = 0; // thare is no left
$checkmiddle = 1; // go to check if there is a middle image
}
else
{
$checkleft = 1; // thare is a left
}
// --------------> uploading left
if ($checkleft ==1)
{
$target = $target . basename( $_FILES['left']['name']) ;
$left=1;
//This is our size condition
if ($uploaded_size > 2050000)
{
echo "הקובץ מעל 2 מגה<br>";
$left=0;
}
//Allowable file ext. names. you may add more extension names.
$file_name = $_FILES['left']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$FILE_EXTS = array('.jpg','.png','.gif','.bmp','.jpeg','.tiff','.tif','.jpe','.pdf');
//Allow file delete? no, if only allow upload only
$DELETABLE = false;
if (!in_array($file_ext, $FILE_EXTS) )
{
echo "הקובץ המצורף בתמונה שמאלית אינו תמונה לכן לא נשלח<br>";
$left=0;
$checkmiddle = 1;
}
//Here we check that $left was not set to 0 by an error
if ($left==0)
{
Echo " ישנה בעיה עם שליחת התמונה השמאלית עליך לשלוחה במייל לכתובת <br>";
$checkmiddle = 1;
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['left']['tmp_name'], $target))
{
echo "הקובץ בשם ". basename( $_FILES['uploadedfile']['name']). " נשלח בהצלחה <br>";
sleep(2) // wait for 2 sec befor start the next upload
$checkmiddle = 1;
}
else
{
echo "ישנה בעיה עם שליחת התמונה השמאלית עליך לשלוחה במייל לכתובת <br>";
$checkmiddle = 1;
}
}
}
// ------------------------ <<<<do the third loop >>>>>----------------
// check if there is a right ===>
if($_FILES['middle']['name']=='')
{
$checkmiddle = 0; // thare is no middle
$checkright = 1; // go to check if there is a right image
}
else
{
$checkmiddle = 1; // thare is a middle
}
// --------------> uploading middle
if ($checkmiddle ==1)
{
$target = $target . basename( $_FILES['middle']['name']) ;
$middle=1;
//This is our size condition
if ($uploaded_size > 2050000)
{
echo "הקובץ מעל 2 מגה<br>";
$middle=0;
}
//Allowable file ext. names. you may add more extension names.
$file_name = $_FILES['middle']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$FILE_EXTS = array('.jpg','.png','.gif','.bmp','.jpeg','.tiff','.tif','.jpe','.pdf');
//Allow file delete? no, if only allow upload only
$DELETABLE = false;
if (!in_array($file_ext, $FILE_EXTS) )
{
echo "הקובץ המצורף כתמונה אמצעית אינו תמונה לכן לא נשלח<br>";
$middle=0;
$checkright = 1;
}
//Here we check that $middle was not set to 0 by an error
if ($middle==0)
{
Echo "ישנה בעיה עם שליחת התמונה האמצעית, עליך לשלוחה במייל לכתובת <br>";
$checkright = 1;
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['middle']['tmp_name'], $target))
{
echo "הקובץ בשם". basename( $_FILES['uploadedfile']['name']). " נשלח בהצלחה <br>";
sleep(2) // wait for 2 sec befor start the next upload
$checkright = 1;
}
else
{
echo "ישנה בעיה עם שליחת התמונה האמצעית, עליך לשלוחה במייל לכתובת <br>";
$checkright = 1;
}
}
}
// ------------------------ <<<<do the fourth loop >>>>>----------------
// check if there is a watever ===>
if($_FILES['right']['name']=='')
{
$checkright = 0; // thare is no right
$checkwatever = 1; // go to check if there is a watever image
}
else
{
$checkright = 1; // thare is a right
}
// --------------> uploading right
if ($checkright ==1)
{
$target = $target . basename( $_FILES['right']['name']) ;
$right=1;
//This is our size condition
if ($uploaded_size > 2050000)
{
echo "הקובץ מעל 2 מגה<br>";
$right=0;
}
//Allowable file ext. names. you may add more extension names.
$file_name = $_FILES['right']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$FILE_EXTS = array('.jpg','.png','.gif','.bmp','.jpeg','.tiff','.tif','.jpe','.pdf');
//Allow file delete? no, if only allow upload only
$DELETABLE = false;
if (!in_array($file_ext, $FILE_EXTS) )
{
echo "הקובץ המצורף כתמונה ימנית אינו תמונה לכן לא נשלח <br>";
$right=0;
$checkwatever = 1;
}
//Here we check that $right was not set to 0 by an error
if ($right==0)
{
Echo "ישנה בעיה עם שליחת התמונה הימנית, עליך לשלוחה במייל לכתובת <br>";
$checkwatever = 1;
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['right']['tmp_name'], $target))
{
echo "הקובץ בשם ". basename( $_FILES['uploadedfile']['name']). " נשלח בהצלחה <br>";
sleep(2) // wait for 2 sec befor start the next upload
$checkwatever = 1;
}
else
{
echo "ישנה בעיה עם שליחת התמונה הימנית, עליך לשלוחה במייל לכתובת <br>";
$checkwatever = 1;
}
}
}
// ------------- finish for this form -----------------------
}
?>
</body>
</html>