I seem to have the same problems as many others who have posted here.
The program is great, I been using it to create various forms and they all work well, now I'm having some problems uploading and insterting data to my site and database, the first problem is, the file does not upload to the established path "use/upload/files" the second problem, is, it adds path,date,and image name to the file, example: http://mysite/form/use/upload/files/11_34_19_Ballerina [Clark].jpg,
What can I do to fix these problems?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Simple solutions.
1.)The files will not be saved if the folder permissions are wrong or the folder does not exist. Set folder permissions to 775 or 777.
2.)This line sets the file name with other data like the date and time (don't be concerned with the path name you see, this is not part of the file name):
$image_part = date("h_i_s")."_".$_FILES['Uploadfileattachment']['name'];
This line copies the file to a specific path:
copy($_FILES['Uploadfileattachment']['tmp_name'], "files/".$image_part);
The path in this case is "files/". This is a relative path from the folder where the form1.html file is located.
You should give some serious consideration to the file name copied to your site. If 2 people copy the same file name, you will loose the first file copied.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code I put in my response was meant to be an example not for you to replace your code with. Your process.php file will require specific changes most likely not included in the example code I gave. If you would like me to check you process.php file, send me the file in an email.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, your file path is "files/" which means the files are being saved to the subfolder files from the folder where the form is.
There is a function that defines a variable called "$where_form_is". This function has not been very consistent for most users. If this does not work you won't get messages that are correct, but from what you've shown me before it looks like this works.
What is your folder structure (directory tree) look like from the form folder down?
There is an upload function that appears to work otherwise you would get the message "was not uploaded!". The copy function just moves the file from a temprary folder to the "files/" folder with no error messages when it fails. I suspect you don't have the right folder permissions for this folder.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
found the solution to my problem, now I'm having a small problem with the links that the email sends out, it seems that it does not handle double name unless you use an underscore, can something be done on the script to fix that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Spaces in file names is never a good idea. It looks great in Windows but it does not port across operating systems very well. Since you have no control over your visitors OS, and you want portability of your code from host to host. The best thing to do is check for proper names (no spaces or illegal characters)before allowing the upload.
I do not recommend providing any mechanism to allow file names with spaces. Therefore I will not even attempt to solve your problem.
Sorry!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I seem to have the same problems as many others who have posted here.
The program is great, I been using it to create various forms and they all work well, now I'm having some problems uploading and insterting data to my site and database, the first problem is, the file does not upload to the established path "use/upload/files" the second problem, is, it adds path,date,and image name to the file, example: http://mysite/form/use/upload/files/11_34_19_Ballerina [Clark].jpg,
What can I do to fix these problems?
Simple solutions.
1.)The files will not be saved if the folder permissions are wrong or the folder does not exist. Set folder permissions to 775 or 777.
2.)This line sets the file name with other data like the date and time (don't be concerned with the path name you see, this is not part of the file name):
$image_part = date("h_i_s")."_".$_FILES['Uploadfileattachment']['name'];
This line copies the file to a specific path:
copy($_FILES['Uploadfileattachment']['tmp_name'], "files/".$image_part);
The path in this case is "files/". This is a relative path from the folder where the form1.html file is located.
You should give some serious consideration to the file name copied to your site. If 2 people copy the same file name, you will loose the first file copied.
I have tried the code you gave me, now I dont get the email notice and the files still dont upload, and it inserts the following to my database.
http://internationalhibiscussociety.org/tellafriend/use/upload/files/02_26_45_
changed code:
$image_part = date("h_i_s")."_".$_FILES['Uploadfileattachment']['name'];
$image_list[0] = $image_part;
copy($_FILES['Uploadfileattachment']['tmp_name'], "files/".$image_part);
The code I put in my response was meant to be an example not for you to replace your code with. Your process.php file will require specific changes most likely not included in the example code I gave. If you would like me to check you process.php file, send me the file in an email.
How can I send an attachment to you
Just cut and paste the file into the email.
Did you get the script?
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
$Bloomimage=$HTTP_POST_FILES['Bloomimage'];
$Podimage=$HTTP_POST_FILES['Podimage'];
$Pollenimage=$HTTP_POST_FILES['Pollenimage'];
$Leafimage=$HTTP_POST_FILES['Leafimage'];
$Hybridiser=$HTTP_POST_FILES['Hybridiser'];
if($HTTP_POST_FILES['Bloomimage']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Bloomimage']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Bloomimage']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Podimage']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Podimage']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Podimage']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Pollenimage']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Pollenimage']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Pollenimage']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Leafimage']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Leafimage']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Leafimage']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Hybridiser']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Hybridiser']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Hybridiser']['name'].", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Bloomimage']['name'];
$image_list[0] = $image_part;
copy($HTTP_POST_FILES['Bloomimage']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Podimage']['name'];
$image_list[1] = $image_part;
copy($HTTP_POST_FILES['Podimage']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Pollenimage']['name'];
$image_list[2] = $image_part;
copy($HTTP_POST_FILES['Pollenimage']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Leafimage']['name'];
$image_list[3] = $image_part;
copy($HTTP_POST_FILES['Leafimage']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Hybridiser']['name'];
$image_list[4] = $image_part;
copy($HTTP_POST_FILES['Hybridiser']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Bloom image: ".$where_form_is."files/".$image_list[0]."
Pod image: ".$where_form_is."files/".$image_list[1]."
Pollen image: ".$where_form_is."files/".$image_list[2]."
Leaf image: ".$where_form_is."files/".$image_list[3]."
Hybridiser: ".$where_form_is."files/".$image_list[4]."
";
$message = stripslashes($message);
mail("xxxxx@xxxx.xx","Form Submitted at your website",$message,"From: phpFormGenerator");
$link = mysql_connect("localhost","xxx_xx","xxxx");
mysql_select_db("xxx_xxx",$link);
$query="insert into upload_image (Bloom_image,Pod_image,Pollen_image,Leaf_image,Hybridiser) values ('".$where_form_is."files/".$image_list[0]."','".$where_form_is."files/".$image_list[1]."','".$where_form_is."files/".$image_list[2]."','".$where_form_is."files/".$image_list[3]."','".$where_form_is."files/".$image_list[4]."')";
mysql_query($query);
?>
<!-- This is the content of the Thank you page, be careful while changing it -->
<h2>Thank you!</h2>
<table width=50%>
<tr><td>Bloom image: </td><td> <?php echo $Bloomimage; ?> </td></tr>
<tr><td>Pod image: </td><td> <?php echo $Podimage; ?> </td></tr>
<tr><td>Pollen image: </td><td> <?php echo $Pollenimage; ?> </td></tr>
<tr><td>Leaf image: </td><td> <?php echo $Leafimage; ?> </td></tr>
<tr><td>Hybridiser: </td><td> <?php echo $Hybridiser; ?> </td></tr>
</table>
<!-- Do not change anything below this line -->
<?php
}
?>
OK, your file path is "files/" which means the files are being saved to the subfolder files from the folder where the form is.
There is a function that defines a variable called "$where_form_is". This function has not been very consistent for most users. If this does not work you won't get messages that are correct, but from what you've shown me before it looks like this works.
What is your folder structure (directory tree) look like from the form folder down?
There is an upload function that appears to work otherwise you would get the message "was not uploaded!". The copy function just moves the file from a temprary folder to the "files/" folder with no error messages when it fails. I suspect you don't have the right folder permissions for this folder.
I have all my folder set to 777, but now I'm getting a server error 500, this is driving me crazy. :(
found the solution to my problem, now I'm having a small problem with the links that the email sends out, it seems that it does not handle double name unless you use an underscore, can something be done on the script to fix that.
Spaces in file names is never a good idea. It looks great in Windows but it does not port across operating systems very well. Since you have no control over your visitors OS, and you want portability of your code from host to host. The best thing to do is check for proper names (no spaces or illegal characters)before allowing the upload.
I do not recommend providing any mechanism to allow file names with spaces. Therefore I will not even attempt to solve your problem.
Sorry!