I have a form which works on a Linix/Apache/PHP server and does not on a Windows/IIS/PHP server.
This form (UNIX-based PHP) works correctly:
http://www.marketingtactics.com/PHP_Tutorials/PHP_RequestInfo_Primer/Lessons/Lesson_32/Lesson32_EmailAttach.php
When you complete the form, a valid email and a READABLE attachment are sent to me.
This form (Windows-based PHP) does not work correctly:
http://www.alamedaeast.com/PHP_Tutorials/PHP_RequestInfo_Primer/Lessons/Lesson_32/Lesson32_EmailAttach.php
I receive the email and what appears to be a valid attachment. However, the attachment can not be opened with the application (e.g., MS Word) or the attachment can be opened, but it is garbled (e.g., a HTML file).
The code is identical on both sites.
Below is what I think is the relevant code:
...
$fp = fopen($newUploadedFilePath,"rb");
$myAttachment = fread($fp,filesize($newUploadedFilePath));
$myAttachment = chunk_split(base64_encode($myAttachment));
fclose($fp);
...
$messageToAcme .= "--" .$mimeBoundary. "\n";
$messageToAcme .= "Content-Type: " .$uploadedFileType ."; name=\"" .$newUploadedFileName ."\"\n";
$messageToAcme .= "Content-Transfer-Encoding: base64\n";
$messageToAcme .= "Content-Disposition: attachment\n";
$messageToAcme .= "\n"; /* This line MUST be here or it won't work */
$messageToAcme .= $myAttachment;
$messageToAcme .= "--" .$mimeBoundary ."--\n";
...
mail($recipientAcme, "Please Send Acme Info", $messageToAcme, $mailAcmeHeaders)
( Complete source code available at http://www.alamedaeast.com/PHP_Tutorials/PHP_RequestInfo_Primer/Lessons/Lesson_32/Lesson32_EmailAttach.phps )
So, what do I do to fix this?
thanks,
dave