폼메일 첨부파일이 안보내집니다ㅠㅠ
</strong></p>
<p><meta charset="utf-8"></p>
<p><?php</p>
<p>if(isset($_POST['email'])) {</p>
<p> </p>
<p> </p>
<p> $email_to = "";</p>
<p> $email_subject = "[폼메일] 공급문의입니다.";</p>
<p> $email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';</p>
<p> </p>
<p> </p>
<p> </p>
<p> function died($error) {</p>
<p> // your error code can go here</p>
<p> echo "<script> alert('견적신청이 실패하였습니다.');";</p>
<p> echo "history.go(-1);";</p>
<p> echo "</script>";</p>
<p> die();</p>
<p> }</p>
<p> </p>
<p> // validation expected data exists</p>
<p> if(!isset($_POST['name']) ||</p>
<p> !isset($_POST['email']) ||</p>
<p> !isset($_POST['telephone']) ||</p>
<p> !isset($_POST['comments'])) {</p>
<p> died('We are sorry, but there appears to be a problem with the form you submitted.'); </p>
<p> }</p>
<p> </p>
<p> // 첨부파일</p>
<p> function attach_file($upfile, $file) {</p>
<p> $fp = @fopen($file, "r");</p>
<p> $tmpfile = array( "name" => $upfile, "data" => @fread($fp, @filesize($file)));</p>
<p> @fclose($fp);</p>
<p> return $tmpfile;</p>
<p> }</p>
<p> </p>
<p> for($i=1, $i<1; $i++){</p>
<p> if($file[$i]['name']=='') continue;</p>
<p> $file_name = $file[$i]['name'];</p>
<p> $header .= "\n--$boundary\n";</p>
<p> $header .= "Content-Type: application/octet-stream\n";</p>
<p> $header .= "Content-Transfer-Encoding: BASE64\n";</p>
<p> $header .= "Content-Disposition: attachment; filename=\"$file_name\"\n";</p>
<p> $header .= "\n";</p>
<p> $header .= base64_encode($file[$i]['data']);</p>
<p> $header .= "\n";</p>
<p> }</p>
<p> </p>
<p> $name = $_POST['name']; // required</p>
<p> $email_from = $_POST['email']; // required</p>
<p> $telephone = $_POST['telephone']; // not required</p>
<p> $comments = $_POST['comments']; // required</p>
<p> </p>
<p> // 여기부터 여분내용작업</p>
<p> $category = $_POST['category'];</p>
<p> $etc1 = $_POST['etc1'];</p>
<p> $etc2 = $_POST['etc2'];</p>
<p> $etc3 = $_POST['etc3'];</p>
<p> $etc4 = $_POST['etc4'];</p>
<p> /*$etc5 = $_POST['etc5'];</p>
<p> $etc6 = $_POST['etc6'];</p>
<p> $etc7 = $_POST['etc7'];</p>
<p> $etc8 = $_POST['etc8'];</p>
<p> $etc9 = $_POST['etc9'];*/</p>
<p> </p>
<p> $error_message = "";</p>
<p> $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';</p>
<p> if(!preg_match($email_exp,$email_from)) {</p>
<p> $error_message .= 'The Email Address you entered does not appear to be valid.<br />';</p>
<p> }</p>
<p> </p>
<p> if(strlen($comments) < 2) {</p>
<p> $error_message .= 'The Comments you entered do not appear to be valid.<br />';</p>
<p> }</p>
<p> if(strlen($error_message) > 0) {</p>
<p> died($error_message);</p>
<p> }</p>
<p> $email_message = "";</p>
<p> </p>
<p> function clean_string($string) {</p>
<p> $bad = array("content-type","bcc:","to:","cc:","href");</p>
<p> return str_replace($bad,"",$string);</p>
<p> }</p>
<p> </p>
<p> </p>
<p> $email_message .= "고객사명 : ".clean_string($name)."
";</p>
<p> $email_message .= "연락처 : ".clean_string($telephone)."
";</p>
<p> $email_message .= "이메일 : ".clean_string($email_from)."
";</p>
<p> $email_message .= "문의내용 : ".clean_string($comments)."
";</p>
<p> $email_message .= "주요 취급상품 카테고리: ".clean_string($etc1)."
";</p>
<p> $email_message .= "판매 주품목 : ".clean_string($etc2)."
";</p>
<p> $email_message .= "원하시는 품목 및 브랜드 : ".clean_string($etc3)."
";</p>
<p> $email_message .= "납품사례 및 이력 : ".clean_string($etc4)."
";</p>
<p>// create email headers</p>
<p>$headers = "Content-Type: text/html; charset=UTF-8\r\n";</p>
<p>$headers .= 'From: '.$email_from;</p>
<p>// 제목이 깨질경우 아래 캐릭터셋 적용</p>
<p> </p>
<p>@mail($email_to, $email_subject, $email_message, $headers, $to_email, $subject, "", $header); </p>
<p>?></p>
<p> </p>
<p><!-- include your own success html here --></p>
<p> </p>
<p><script></p>
<p>alert ("문의주셔서 감사합니다.\n빠른 시일안에 답변드리겠습니다.");</p>
<p>window.location = document.referrer;</p>
<p></script></p>
<p> </p>
<p><?php</p>
<p>}</p>
<p>?></p>
<p><strong>
답변을 작성하려면 로그인이 필요합니다.
로그인