폼메일에 첨부한 이미지가 메일로 전송이 안됩니다...

폼메일에 첨부한 이미지가 메일로 전송이 안됩니다...

QA

폼메일에 첨부한 이미지가 메일로 전송이 안됩니다...

본문

formmail.php

 


<form class="regFormFrame" name="contactform" method="post" action="send.php">
 
  <table>
 
    <tr>
 
      <th scope="row">
 
      <span class="req">이름</span>
      
      </th>
 
      <td width="80%">
 
      <input name="first_name"  type="text" class="ipt" style="height:30px;border:1px solid #ececec; " size="30" maxlength="50" required >
 
      </td>
 
    </tr>
    
    <tr>
 
      <th scope="row">
 
      <span for="telephone">연락처</span></th>
 
      <td>
 
      <input name="telephone"  type="text" class="ipt" style="height:30px;border:1px solid #ececec;" size="30" maxlength="30" required >
 
      </td>
 
    </tr>
    
    <tr>
 
      <th scope="row">
 
      <span for="email">이메일 주소</span></th>
 
      <td>
 
      <input name="email"  type="text" placeholder="000@0000.000" class="ipt" style="height:30px;border:1px solid #ececec;" size="30" maxlength="80" required >
 
      </td>
 
    </tr>
    
 
    <tr>
 
      <th scope="row">
 
      <span for="place">시공 지역</span></th>
 
      <td>
 
      <input name="place"  type="text" placeholder="ex. 인천 부평구" class="ipt" style="height:30px;border:1px solid #ececec;" size="30" maxlength="30" required >
 
      </td>
 
    </tr>
 
    <tr class="wr_6 radio">
 
      <th scope="row">
        <span class="req">공간정보</span>
      </th>
      
      <td>
        <label><input type="radio" name="wr_6_radio" value="아파트"> 아파트 </label><label><input type="radio" name="wr_6_radio" value="빌라"> 빌라 </label>
        <label><input type="radio" name="wr_6_radio" value="아파트"> 상업공간 </label><label><input type="radio" name="wr_6_radio" value="빌라"> 주택 </label><label><input type="radio" name="wr_6_radio" value="빌라"> 기타 </label>
      </td>
    </tr>
    
    <!-- 파일첨부 퍼옴 -->
    <!-- <tr class="attachment_max" height='30'>
      <td width='20%' align='center' class='formmail_title_bgcolor'>
            <font style='color:#7c7c7c; font-weight:bold;'>파일첨부</font></td>
      <td width='80%' style='padding-left:10' class='formmail_cell_bgcolor'>
        <input type='hidden' class='formmail_border' name='attachment_max' value='2'>
        <input type='file' class='formmail_border' name='attachment[]' size='55'><br>
      </td>
    </tr> -->
    <input type="file" name="file" class="frm_input">
    <!-- 파일첨부 퍼옴 끝 -->
 
    <th scope="row">
 
      <span for="comments">문의내용</span></th>
 
      <td height="170" valign="bottom">
 
        <textarea  name="comments" cols="50" rows="10" style="width:95%;border:1px solid #ececec;" required ></textarea></td>
 
    </tr>
 
<!-- 개인정보 퍼옴 -->
    <tr>
        <!-- <td class='formmail_cell_bgcolor' colspan="2" style="padding : 10px"> -->
            <tr>
                <td align="left" style="border:0px">· 개인정보의 수집 및 이용목적</td>
                <td align="right" style="border:0px"><input type='checkbox' name='com_formmail_check_safe'> 개인정보의 수집 및 이용목적에 동의합니다.</td>
            </tr>
            <tr>
                <td colspan="2" style="border:0px">
                  <textarea readonly style="font-size:12px; width:100%; padding:5px; border:1px solid #ececec;color: #383838;" rows="9">
                        ㅇㅇㅇ은
                        별도의 회원가입 절차 없이 대부분의 신청관련 컨텐츠에 자유롭게 접근할 수 있습니다.
                        회사는 서비스 이용을 위하여 아래와 같은 개인정보를 수집하고 있습니다.
                        1) 수집하는 개인정보의 범위
                        
                        ■ 필수항목
                        - 이름, 연락처
                        1. 개인정보의 수집 및 이용 목적
                        가맹 관련 문의 확인 및 답변을 위한 연락통지,
                        처리결과 통보 등을 목적으로 개인정보를 처리합니다.
                        
                        2. 처리하는 개인정보 항목
                        - 필수항목 : 이름, 연락처 (접속 IP 정보, 쿠키,
                        서비스 이용 기록, 접속 로그)
                        - 선택항목 : 이메일
 
                        3. 개인정보의 처리 및 보유 기간
                        ① 법령에 따른 개인정보 보유.이용기간 또는
                        정보주체로부터 개인정보를 수집 시에 동의 받은 개인정보 보유,
                        이용기간 내에서 개인정보를 처리, 보유합니다.
                        ② 개인정보의 보유 기간은 5년입니다.
                  </textarea>
                </td>
              </tr>
        </td>
    </tr>
<!-- 개인정보 퍼옴 끝 -->
 
    <tr>
 
      <td height="40" colspan="2" style="text-align:center; background:none; border:none;">
 
      <input type="submit" value="문의하기" class="btn_submit">
 
      <input name="재설정" type="reset" value="다시작성" class="btn_submit"></td>
 
    </tr>
  </table>
 
</form>
 
<script>
 
  $(function() {
 
      $(".privacyView").click(function(){
 
      $(".regFormPrivacy").show();
 
    });

 
    $(".privacyCloseBtn").click(function(){
 
      $(".regFormPrivacy").hide();
 
    });
 
  });
</script>

 

 

send.php


<?php
 
if(isset($_POST['email'])) {
 
     
 
    
 
  $email_to = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
 
  $email_subject = "[ddd] 견적 문의사항입니다.";
 
  $email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';

 
     
 
     
 
    function died($error) {
 
        // your error code can go here
 
        echo "<script> alert('메일발송을 실패하였습니다.');";
 
    echo "history.go(-1);";
 
    echo "</script>";
 
        die();
 
    }
     
 
    // validation expected data exists
 
    if(!isset($_POST['first_name']) ||
 
        !isset($_POST['telephone']) ||
        
        !isset($_POST['email']) ||
 
        !isset($_POST['place']) ||
 
        !isset($_POST['wr_6_radio']) ||
 
        !isset($_POST['file']) ||
 
        !isset($_POST['comments'])) {
 
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
 
    }
 
    if($mode == "send") {
      //파일첨부 시작
      for($i=1;$i<=3;$i++) {
          $file[$i] = $_FILES['userfile'.$i]['name'];
          $target[$i] = "./temp/".$file[$i];
  
          if (move_uploaded_file($_FILES['userfile'.$i]['tmp_name'], $target[$i])) {
              chmod("$target[$i]", 0777);
          }
      }
  
      $ret = mailer($name, $email, "Admin", $admin_email, $subject, $body.$body2, $file);
  
      if($file[1] != "") @unlink($target[1]);
      if($file[2] != "") @unlink($target[2]);
      if($file[3] != "") @unlink($target[3]);
        
 
    $first_name = $_POST['first_name']; // required
 
    $telephone = $_POST['telephone']; // not required
 
    $email_from = $_POST['email']; // required
 
    $comments = $_POST['comments']; // required
 
    $place = $_POST['place']; // required 
 
    $wr_6_radio = $_POST['wr_6_radio']; // required
 
    $file = $_POST['file']; // required
 
    // $file = attach_file($_FILES['file1']['name'], $_FILES['file1']['tmp_name']);
 
    
    $error_message = "";
 
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
 
  if(!preg_match($email_exp,$email_from)) {
 
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
 
  }
 
    
 
  if(strlen($comments) < 2) {
 
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
 
  }
 
  if(strlen($error_message) > 0) {
 
    died($error_message);
 
  }
 
    $email_message = "";
 
     
 
    function clean_string($string) {
 
      $bad = array("content-type","bcc:","to:","cc:","href");
 
      return str_replace($bad,"",$string);
 
    }
 
     
 
    $email_message .= "이름 : ".clean_string($first_name)."\n\n";
 
    $email_message .= "연락처 : ".clean_string($telephone)."\n\n";
    
    $email_message .= "이메일 : ".clean_string($email_from)."\n\n";
 
    $email_message .= "시공 지역 : ".clean_string($place)."\n\n";
    
    $email_message .= "공간정보 : ".clean_string($wr_6_radio)."\n\n";
 
    $email_message .= "첨부파일 : ".clean_string($file)."\n\n";
 
    $email_message .= "문의사항 : ".clean_string($comments)."\n\n";
 
     
 
     
 
// create email headers
 
$headers = 'From: '.$email_from;
 
// 제목이 깨질경우 아래 캐릭터셋 적용

 
@mail($email_to, $email_subject, $email_message, $headers);  
 
?>
 
 
 
<!-- include your own success html here -->
 
 
 
<script>
 
alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
 
location.href='../';
 
</script>
 
 
 
<?php
 
}
 
?>

 

제발 알려주세요....

이 질문에 댓글 쓰기 :

답변 1

 $file = $_POST['file']; // required

이 부분이 _POST로는 직접 안 넘어 올 것 같은데요. 

 

여기를 수정한 것인지,  아래 커멘트한 부분이 더 맞을 것 같습니다.

 

수정한 부분이 어디 어디인지를 알려주시면 답변 받기가 조금 더 쉬울것 같습니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 1,096
QA 내용 검색
filter #html ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT