Dev01 Posted June 19, 2008 Share Posted June 19, 2008 Hello all I have posted this issue on several other PHP forums, unfortunately, I have not been able to resolve this problem as of yet. Any help would be great. I have an HTML form, which posts to a PHP file that processes a number of fields and an attachment for pictures/images. This works perfectly in Firefox, however, in Internet Explorer small picture files are fine, but larger ones are inconsistent. I can send a 654kb image one time which will work, other times it will not. It has been suggested that I just use PHP Mailer, however, I have already spent time on this form and would like to find a resolution for this before attacking it all over again. The code is below: <?php 2. 3. 4. $strname=ucfirst($_REQUEST["strname"]); 5. $straddress=ucfirst($_REQUEST["straddress"]); 6. $strcity=ucfirst($_REQUEST["strcity"]); 7. $strstate=ucfirst($_REQUEST["strstate"]); 8. 9. $phone=$_REQUEST["strno"]; 10. if($phone != ""){ $strno=$phone; } else { $strno="-"; } 11. 12. $stremail=$_REQUEST["stremail"]; 13. $strcomments=ucfirst($_REQUEST["strcomments"]); 14. 15. 16. $filename=$_FILES["strresume"]["name"]; 17. $filetype=$_FILES["strresume"]["type"]; 18. $filesize=$_FILES["strresume"]["size"]; 19. $filetemp=$_FILES["strresume"]["tmp_name"]; 20. 21. 22. 23. if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword" or $filetype=="image/jpg" or $filetype=="image/jpeg" or $filetype=="image/bmp" or $filetype=="image/JPG" or $filetype=="images/jpe" or $filetype=="image/gif" or $filetype=="images/eps" or $filetype=="images/tiff" or $filetype=="images/psd" or $filetype=="application/pdf" or $filetype=="application/cdr") 24. { 25. 26. $message= ' 27. 28. 29. <table cellspacing="0" cellpadding="8" border="0" width="400"> 30. <tr> 31. <td colspan="2"></td> 32. </tr> 33. <tr bgcolor="#eeeeee"> 34. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td> 35. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strname.'</td> 36. </tr> 37. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 38. <tr bgcolor="#eeeeee"> 39. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td> 40. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$straddress.'</td> 41. </tr> 42. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 43. <tr bgcolor="#eeeeee"> 44. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>County</strong></td> 45. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcity.'</td> 46. </tr> 47. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 48. <tr bgcolor="#eeeeee"> 49. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Postcode</strong></td> 50. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strstate.'</td> 51. </tr> 52. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 53. <tr bgcolor="#eeeeee"> 54. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Telephone</strong></td> 55. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strno.'</td> 56. </tr> 57. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 58. <tr bgcolor="#eeeeee"> 59. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Email</strong></td> 60. <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$stremail.'</td> 61. </tr> 62. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 63. 64. <tr bgcolor="#eeeeee"> 65. <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Sending by post?</strong></td> 66. </tr> 67. <tr bgcolor="#eeeeee"> 68. <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcomments.'</td> 69. </tr> 70. 71. <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr> 72. </table> 73. 74. 75. 76. 77. '; 78. 79. // MAIL SUBJECT 80. 81. $subject = "Customer Image Attachment"; 82. 83. // TO MAIL ADDRESS 84. 85. 86. $to="info@somewhere.co.uk"; 87. 88. /* 89. // MAIL HEADERS 90. 91. $headers = "MIME-Version: 1.0\n"; 92. $headers .= "Content-type: text/html; charset=iso-8859-1\n"; 93. $headers .= "From: Name <name@name.com>\n"; 94. 95. */ 96. 97. 98. 99. // MAIL HEADERS with attachment 100. 101. $fp = fopen($strresume, "rb"); 102. $file = fread($fp, $strresume_size); 103. 104. $file = chunk_split(base64_encode($file)); 105. $num = md5(time()); 106. 107. //Normal headers 108. 109. $headers = "From: My website\r\n"; 110. $headers .= "MIME-Version: 1.0\r\n"; 111. $headers .= "Content-Type: multipart/mixed; "; 112. $headers .= "boundary=".$num."\r\n"; 113. $headers .= "--$num\r\n"; 114. 115. // This two steps to help avoid spam 116. 117. $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; 118. $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; 119. 120. // With message 121. 122. $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 123. $headers .= "Content-Transfer-Encoding: 8bit\r\n"; 124. $headers .= "".$message."\n"; 125. $headers .= "--".$num."\n"; 126. 127. // Attachment headers 128. 129. $headers .= "Content-Type:".$strresume_type." "; 130. $headers .= "name=\"".$strresume_name."\"r\n"; 131. $headers .= "Content-Transfer-Encoding: base64\r\n"; 132. $headers .= "Content-Disposition: attachment; "; 133. $headers .= "filename=\"".$strresume_name."\"\r\n\n"; 134. $headers .= "".$file."\r\n"; 135. $headers .= "--".$num."--"; 136. 137. 138. 139. // SEND MAIL 140. 141. @mail($to, $subject, $message, $headers); 142. 143. 144. fclose($fp); 145. 146. echo "<script>window.location.href='order.html';</script>"; 147. } 148. else 149. { 150. echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Incorrect file format, please ensure your image is one of the following: PDF, JPG/JPEG, TIFF, EPS, PSD, CDR, BMP, thank you, please go back and try again.</font>'; 151. //echo "<script>window.location.href='careers.html';</script>"; 152. } 153. 154. ?> This is becoming very frustrating, Internet Explorer is the developers worst nightmare! Thanks Dev01 Quote Link to comment https://forums.phpfreaks.com/topic/110907-php-attachment-form-not-working-with-ie/ Share on other sites More sharing options...
MadTechie Posted June 19, 2008 Share Posted June 19, 2008 you could try this <?php //Add set_time_limit(0); ini_set ("memory_limit", "64M"); 99. // MAIL HEADERS with attachment 100. 101. $fp = fopen($strresume, "rb"); 102. $file = fread($fp, $strresume_size); ?> Quote Link to comment https://forums.phpfreaks.com/topic/110907-php-attachment-form-not-working-with-ie/#findComment-568993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.