<form action="php_pro/contact_us_send.php" method="post" name="form2" id="form2" onSubmit="return validateForm()" enctype="multipart/form-data"> <table width="400" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td height="7" colspan="2"></td> </tr> <tr> <td colspan="2" align="left" class="style8"><span class="style17"><span class="style1">สนใจบริการ</span> / <span class="style1">แนะนำติชมบริการ</span> / <span class="style1">สั่งซื้อสินค้า</span></span></td> </tr> <tr> <td width="76" align="right" class="style8"><div align="left" class="style24"><span class="style47">ชื่อผู้ติดต่อ :</span></div></td> <td align="left"><div align="left"> <input name="userFirstName" type="text" id="userFirstName" size="40" maxlength="50"> </div></td> </tr> <tr> <td align="right" class="style8"><div align="left" class="style24"><span class="style47">E-mail :</span></div></td> <td align="left"><div align="left"> <input name="userEmail" type="text" id="userEmail" size="40"> </div></td> </tr> <tr> <td align="right" class="style8"><div align="left" class="style24"><span class="style47">โทรศัพท์ :</span></div></td> <td align="left"><div align="left"> <input name="userPhone" type="text" id="userPhone" size="40"> </div></td> </tr> <tr> <td align="right" valign="top" class="style8"><div align="left" class="style24"><span class="style47">ข้อความ :</span></div></td> <td align="left"><div align="left"> <textarea name="userComment" cols="30" rows="7" id="textarea3"></textarea> </div></td> </tr> <tr> <td valign="top"><div align="left" class="style24"><span class="style47">Image :</span></div></td> <td align="left"><label> <input type="file" name="imageSend" id="imageSend"> </label></td> </tr> <tr> <td valign="top"> </td> <td align="left"><div align="left"> <input name="imageField2" type="submit" value="ส่งข้อความ"> <input type="reset" name="Reset" value="ลบข้อความ"> </div></td> </tr> </table> </form>
<? $strTo = "[email protected]"; $strSubject = $_POST[userFirstName]; $strMessage = nl2br($_POST[userComment]); //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: ".$_POST[userFirstName]."<".$_POST[userEmail].">\nReply-To: ".$_POST[userEmail].""; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=UTF-8\n"; // or UTF-8 // $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; //*** Attachment ***// if($_FILES["imagesSend"]["name"] != ""){ $strFilesName = $_FILES["imagesSend"]["name"]; $strContent = chunk_split(base64_encode(file_get_contents($_FILES["imagesSend"]["tmp_name"]))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n"; $strHeader .= $strContent."\n\n"; } $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend){ echo "<script>alert('Email send successfully.')</script>"; echo "<meta http-equiv='refresh' content='0; url=../home.php'>"; }else{ echo "<script>alert('Email Can Not Send')</script>"; echo "<meta http-equiv='refresh' content='0; url=../home.php'>"; } ?>
Quote:<input type="file" name="imageSend" id="imageSend">
Quote:$_FILES["imagesSend"]["name"];
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง