jlknauff
06-27-2006, 08:04 AM
I have a form here: http://www.wildfiremarketinggroup.com/form1.html
And have added a bit of code that I thought was correct (line 3) to replace spaces with and underscore because if someone uploaded a file with a space in the name, the link to it on the server got broken. In any case, it doesn't work.
Here is my php:
<?php
include("global.inc.php");
$temp = str_replace(" "_"", $temp);
echo $temp;
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Contactname');
pt_register('POST','Phonenumber');
pt_register('POST','Emailaddress');
$File1=$HTTP_POST_FILES['File1'];
$File2=$HTTP_POST_FILES['File2'];
$File3=$HTTP_POST_FILES['File3'];
$File4=$HTTP_POST_FILES['File4'];
$File5=$HTTP_POST_FILES['File5'];
$File6=$HTTP_POST_FILES['File6'];
$Comments=$HTTP_POST_FILES['Comments'];
if($Contactname=="" || $Phonenumber=="" || $Emailaddress=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($HTTP_POST_FILES['File1']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File1']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File1']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File2']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File2']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File2']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File3']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File3']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File3']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File4']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File4']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File4']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File5']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File5']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File5']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File6']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File6']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File6']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Comments']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Comments']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Comments']['name'].", was not uploaded!";
$errors=1;
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Emailaddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File1']['name'];
$image_list[3] = $image_part;
copy($HTTP_POST_FILES['File1']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File2']['name'];
$image_list[4] = $image_part;
copy($HTTP_POST_FILES['File2']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File3']['name'];
$image_list[5] = $image_part;
copy($HTTP_POST_FILES['File3']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File4']['name'];
$image_list[6] = $image_part;
copy($HTTP_POST_FILES['File4']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File5']['name'];
$image_list[7] = $image_part;
copy($HTTP_POST_FILES['File5']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File6']['name'];
$image_list[8] = $image_part;
copy($HTTP_POST_FILES['File6']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Comments']['name'];
$image_list[9] = $image_part;
copy($HTTP_POST_FILES['Comments']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Contact name: ".$Contactname."
Phone number: ".$Phonenumber."
Email address: ".$Emailaddress."
File 1: ".$where_form_is."files/".$image_list[3]."
File 2: ".$where_form_is."files/".$image_list[4]."
File 3: ".$where_form_is."files/".$image_list[5]."
File 4: ".$where_form_is."files/".$image_list[6]."
File 5: ".$where_form_is."files/".$image_list[7]."
File 6: ".$where_form_is."files/".$image_list[8]."
Comments: ".$where_form_is."files/".$image_list[9]."
";
$message = stripslashes($message);
mail("print@wildfiremarketinggroup.com","File upload form",$message,"From: $Email");
header("Refresh: 0;url=http://www.wildfiremarketinggroup.com");
?><?php
}
?>
Any ideas? Also - the script needs to be able to upload large files (>10mb). Is this a setting on the server that needs to be changed or am I taking the wrong approach here?
And have added a bit of code that I thought was correct (line 3) to replace spaces with and underscore because if someone uploaded a file with a space in the name, the link to it on the server got broken. In any case, it doesn't work.
Here is my php:
<?php
include("global.inc.php");
$temp = str_replace(" "_"", $temp);
echo $temp;
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Contactname');
pt_register('POST','Phonenumber');
pt_register('POST','Emailaddress');
$File1=$HTTP_POST_FILES['File1'];
$File2=$HTTP_POST_FILES['File2'];
$File3=$HTTP_POST_FILES['File3'];
$File4=$HTTP_POST_FILES['File4'];
$File5=$HTTP_POST_FILES['File5'];
$File6=$HTTP_POST_FILES['File6'];
$Comments=$HTTP_POST_FILES['Comments'];
if($Contactname=="" || $Phonenumber=="" || $Emailaddress=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($HTTP_POST_FILES['File1']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File1']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File1']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File2']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File2']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File2']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File3']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File3']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File3']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File4']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File4']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File4']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File5']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File5']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File5']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File6']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['File6']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File6']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Comments']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Comments']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Comments']['name'].", was not uploaded!";
$errors=1;
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Emailaddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File1']['name'];
$image_list[3] = $image_part;
copy($HTTP_POST_FILES['File1']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File2']['name'];
$image_list[4] = $image_part;
copy($HTTP_POST_FILES['File2']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File3']['name'];
$image_list[5] = $image_part;
copy($HTTP_POST_FILES['File3']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File4']['name'];
$image_list[6] = $image_part;
copy($HTTP_POST_FILES['File4']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File5']['name'];
$image_list[7] = $image_part;
copy($HTTP_POST_FILES['File5']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File6']['name'];
$image_list[8] = $image_part;
copy($HTTP_POST_FILES['File6']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Comments']['name'];
$image_list[9] = $image_part;
copy($HTTP_POST_FILES['Comments']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Contact name: ".$Contactname."
Phone number: ".$Phonenumber."
Email address: ".$Emailaddress."
File 1: ".$where_form_is."files/".$image_list[3]."
File 2: ".$where_form_is."files/".$image_list[4]."
File 3: ".$where_form_is."files/".$image_list[5]."
File 4: ".$where_form_is."files/".$image_list[6]."
File 5: ".$where_form_is."files/".$image_list[7]."
File 6: ".$where_form_is."files/".$image_list[8]."
Comments: ".$where_form_is."files/".$image_list[9]."
";
$message = stripslashes($message);
mail("print@wildfiremarketinggroup.com","File upload form",$message,"From: $Email");
header("Refresh: 0;url=http://www.wildfiremarketinggroup.com");
?><?php
}
?>
Any ideas? Also - the script needs to be able to upload large files (>10mb). Is this a setting on the server that needs to be changed or am I taking the wrong approach here?