PDA

View Full Version : Email Attachment Woes


paputxi
10-18-2009, 05:41 PM
I am having great difficulties in creating an online form where a visitor can attach a file from their computer that is then emailed to me. In trying to troubleshoot the problem, I created an empty website that I then populated with just the WA Contact Form Solution Pack files. I then modified the contactus.php file by adding a file field element at the top of the form per the WA "Inserting Additional form fields to your Contact Form". I then followed the directions of WA's "How To Include Attachments with your Email form" to indicate the Server Directory and Server File Name entries. I also created a folder in my website, "attachments", and added that to the path for these two entries.

However, this did not work, so I then tried removing the Server Directory entry as identified in the Debugging section of "include" paper. That too, did not work. I also tried NOT specifying the "attachments" folder for the above mentioned server directory and file name combinations, but they too did not work. (Note: Each time I made a change, I uploaded the whole site to make sure I wasn't missing a file somewhere. Note too, that I do get the text fields in the emails I receive, just not the attached file.

I'm enclosing the contactus.php and associated WAUE_contact_1.php files in hopes that someone can see what I am doing wrong. Any thoughts on how I correct this would be greatly appreciated. Thanks in advance.

Jason Byrnes
10-19-2009, 10:28 AM
In the WAUE_contact_1.php file, line 25:


$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"attachments/".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"] ."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."");


should be:
$WA_MailObject = WAUE_AddAttachment($WA_MailObject, "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"] ."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."");


If you are still having problems, lets make sure the server file name is being set. Change line 25 to:
die("".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"] ."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."");
$WA_MailObject = WAUE_AddAttachment($WA_MailObject, "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverDirectory"] ."".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."");



This will write the server file name and upload folder to the screen, post this value back.

paputxi
10-19-2009, 12:46 PM
Didn't work, so I ran your last code. Results provided below. Also, in case it helps you, attached is the HelperPHP.php file.

Warning: mkdir() [function.mkdir]: No such file or directory in D:\Hosting\4491668\html\CFSP2\WA_DigitalFilePro\He lperPHP.php on line 30

Warning: move_uploaded_file(D:/Hosting/4491668/html/CFSP2/contactus.php/attachments\44bcfc577e25e2c6258bd82b1b07f5d0_tmp.d oc) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Hosting\4491668\html\CFSP2\WA_DigitalFilePro\He lperPHP.php on line 96

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php5523.tmp' to 'D:/Hosting/4491668/html/CFSP2/contactus.php/attachments\44bcfc577e25e2c6258bd82b1b07f5d0_tmp.d oc' in D:\Hosting\4491668\html\CFSP2\WA_DigitalFilePro\He lperPHP.php on line 96

Warning: copy(D:/Hosting/4491668/html/CFSP2/contactus.php/attachments\44bcfc577e25e2c6258bd82b1b07f5d0_tmp.d oc) [function.copy]: failed to open stream: No such file or directory in D:\Hosting\4491668\html\CFSP2\WA_DigitalFilePro\He lperPHP.php on line 98

Jason Byrnes
10-19-2009, 01:50 PM
That basically means the upload directory does not exist and there are no privlages t ocreate it.



Try changing line 33 of the contact us page:

'UploadFolder' => "/attachments",


to:
'UploadFolder' => "attachments",



and make sure that there is a folder called "attachments" in the same folder as the contact us page.

paputxi
10-19-2009, 03:25 PM
Success!! Using your debugging techniques (which gave me more insight as to what was happening, or in this case NOT happening) and setting the permission to the attachments folder on the website to be "read-write" (BIG part of the problem, for sure), I was able to resolve the problem. Thanks for your support on this, Jason! You can mark this issue RESOLVED.

Jason Byrnes
10-19-2009, 03:45 PM
excellent, glad to hear it's working.

paputxi
10-19-2009, 03:50 PM
Turns out it is "almost" working. Now I need to get it to accept .doc file types (which is what I need) and not just.jpg files (which is what I was testing with). Unless you have a suggestion regarding that, I'll go over to the Digital File Pro forum to see what I can find out.

But, you were a big help, Jason. Thanks again.

paputxi
10-19-2009, 04:14 PM
Never mind. It appears to be working just fine now.

Thanks once again for your support, Jason.