폼메일에 파일첨부 하는 방법ㅠㅠ

폼메일에 파일첨부 하는 방법ㅠㅠ

QA

폼메일에 파일첨부 하는 방법ㅠㅠ

답변 1

본문

여태 질문 올리신분들 답변 다따라해봤는데

제가 너무너무초보라서 아무것도 안되네요 ㅠㅠ....

 

폼코드 입니다 .ㅠㅠ..


<form class="uk-form-horizontal uk-margin-large" onsubmit="return fformmail_submit(this);" name="fformmail" method="post" enctype="multipart/form-data" action="../theme/design/template/estimate2/send.php">
            <input type="hidden" name="to" value="<?php echo $email ?>">
            <input type="hidden" name="attach" value="2">
            <?php if ($is_member) { // 회원이면  ?>
            <input type="hidden" name="fnick" value="<?php echo get_text($member['mb_nick']) ?>">
            <input type="hidden" name="fmail" value="<?php echo $member['mb_email'] ?>">
            <?php }  ?>
            <input type="hidden" name="to" value="<?php echo $email ?>">
            <input type="hidden" name="attach" value="2">
            <input type="hidden" name="fnick" value="<?php echo get_text($member['mb_nick']) ?>">
            <hr>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb1_company">회사명</label>
                <div class="uk-form-controls">
                    <input name="pcb1_company" class="uk-input" id="form-horizontal-text" type="text" placeholder="회사명을 입력해주세요.">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb2_name">성명</label>
                <div class="uk-form-controls">
                    <input name="pcb2_name" class="uk-input" id="form-horizontal-text" type="text" placeholder="성명을 입력해주세요.">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb3_mail">이메일</label>
                <div class="uk-form-controls">
                    <input name="pcb3_mail" class="uk-input" id="form-horizontal-text" type="text" placeholder="이메일을 입력해주세요.">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb4_tel1">전화번호</label>
                <div class="uk-form-controls">
                    <input name="pcb4_tel1" class="uk-input" id="form-horizontal-text" type="text">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb5_phone1">휴대폰번호</label>
                <div class="uk-form-controls">
                    <input name="pcb5_phone1" class="uk-input" id="form-horizontal-text" type="text">
                </div>
            </div>
            <hr>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb6_title">제목</label>
                <div class="uk-form-controls">
                    <input name="pcb6_title" class="uk-input" id="form-horizontal-text" type="text" placeholder="제목을 입력해주세요.">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb7_tool">실장 자재 종 수 / 1PSC</label>
                <div class="uk-form-controls">
                    <input name="pcb7_tool" class="uk-input uk-width-1-2@s" id="form-horizontal-text" type="text">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb8_layer">실장 점수/1PSC</label>
                <div class="uk-form-controls">
                    <input name="pcb8_layer" class="uk-input uk-width-1-2@s" id="form-horizontal-text" type="text">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb9_num">진행 수량</label>
                <div class="uk-form-controls">
                    <input name="pcb9_num" class="uk-input uk-width-1-2@s" id="form-horizontal-text" type="text" placeholder="Sheet">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb10_size1">B/D Size</label>
                <div class="uk-form-controls">
                    <input name="pcb10_size1" class="uk-input uk-width-1-2@s" id="form-horizontal-text" type="text" placeholder="mm">
                </div>
            </div>

            <div class="uk-margin">
                <label class="uk-form-label" for="pcb11_day">희망납기일</label>
                <div class="uk-form-controls">
                    <input name="pcb11_day" class="uk-input uk-width-1-2@s" id="form-horizontal-text" type="text">
                </div>
            </div>
            <div class="uk-margin">
                <label class="uk-form-label" for="pcb12_index">문의내용</label>
                <div class="uk-form-controls">
                    <textarea name="pcb12_index" class="uk-textarea textbox" rows="10"></textarea>
                </div>
            </div>

            <div class="uk-margin formmail_flie">
                <div class="file_wr">
                    <label for="file1" class="lb_icon"><i class="fa fa-download" aria-hidden="true"></i><span class="sound_only"> 첨부 파일 1</span></label>
                    <input type="file" name="file1" id="file1" class="frm_file full_input">
                </div>
            </div>

            <div class="win_btn">
                <input type="submit" value="메일발송" id="btn_submit" class="btn_submit">
                <button type="button" onclick="window.close();" class="btn_close">창닫기</button>
            </div>
        </form>

 

send.php 코드입니다.

뭐를 어떻게해야하나요...?ㅠㅠ

 


<meta charset="utf-8">
<?php
include_once(G5_LIB_PATH.'/mailer.lib.php');
if(isset($_POST['pcb3_mail'])) {
    
$email_to = "아이디.com";
$email_subject = "[시스템] SMT 문의사항입니다.";
$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';
for($i=1;$i<=3;$i++) { 
   if($file[$i]['name'] == '') continue; 
   $file_name = $file[$i]['name']; 
   $header .= "\n--$boundary\n"; 
   $header .= "Content-Type: application/octet-stream\n"; 
   $header .= "Content-Transfer-Encoding: BASE64\n"; 
   $header .= "Content-Disposition: attachment; filename=\"$file_name\"\n"; 
   $header .= "\n"; 
   $header .= base64_encode($file[$i]['data']); 
   $header .= "\n"; 
}
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['pcb1_company']) ||
!isset($_POST['pcb2_name']) ||
!isset($_POST['pcb3_mail']) ||
!isset($_POST['pcb4_tel1']) ||
!isset($_POST['pcb5_phone1']) ||
!isset($_POST['pcb6_title']) ||
!isset($_POST['pcb7_tool']) ||
!isset($_POST['pcb8_layer']) ||
!isset($_POST['pcb9_num']) ||
!isset($_POST['pcb10_size1']) ||
!isset($_POST['pcb11_day']) ||
!isset($_POST['pcb12_index'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');       
}
$pcb1_company = $_POST['pcb1_company']; // required
$pcb2_name = $_POST['pcb2_name']; // required
$email_from = $_POST['pcb3_mail']; // required
$pcb4_tel1 = $_POST['pcb4_tel1']; // not required
$pcb5_phone1 = $_POST['pcb5_phone1']; // not required
$pcb6_title = $_POST['pcb6_title']; // required
$pcb7_tool = $_POST['pcb7_tool']; // not required
$pcb8_layer = $_POST['pcb8_layer']; // not required
$pcb9_num = $_POST['pcb9_num']; // not required
$pcb10_size1 = $_POST['pcb10_size1']; // not required
$pcb11_day = $_POST['pcb11_day']; // not required
$pcb12_index = $_POST['pcb12_index']; // not required
    
    
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "회사명 : ".clean_string($pcb1_company)."\n\n";
$email_message .= "성명 : ".clean_string($pcb2_name)."\n\n";
$email_message .= "이메일 : ".clean_string($email_from )."\n\n";
$email_message .= "전화번호 : ".clean_string($pcb4_tel1)."\n\n";
$email_message .= "휴대폰번호 : ".clean_string($pcb5_phone1)."\n\n";
$email_message .= "제목 : ".clean_string($pcb6_title)."\n\n";
$email_message .= "실장 자재 종 수 / 1PSC : ".clean_string($pcb7_tool)."\n\n";
$email_message .= "실장 점수/1PSC : ".clean_string($pcb8_layer)."\n\n";
$email_message .= "진행 수량 : ".clean_string($pcb9_num)."\n\n";
$email_message .= "B/D Size : ".clean_string($pcb10_size1)."\n\n";
$email_message .= "희망납기일 : ".clean_string($pcb11_day)."\n\n";
$email_message .= "문의내용 : ".clean_string($pcb12_index)."\n\n";

 $file = array();
for ($i=1; $i<=$attach; $i++) {
    if ($_FILES['file'.$i]['name'])
        $file[] = attach_file($_FILES['file'.$i]['name'], $_FILES['file'.$i]['tmp_name']);

// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용
    
 
@mail($email_to, $email_subject, $email_message, $headers, $file);  
 
// 임시 첨부파일 삭제
if(!empty($file)) {
    foreach($file as $f) {
        @unlink($f['path']);
    }
}
    
?>
<!-- include your own success html here -->
<script>
    alert("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
    location.href = '/bbs/content.php?co_id=estimate2';
</script>
<?php
}
?>

이 질문에 댓글 쓰기 :

답변 1

폼메일 양식이 저장된 위치가 /bbs/content.php?co_id=estimate2  인듯싶은데

컨텐츠내용관리 영역에는 form 이 작동하지 않습니다

물론 그누보드 소스를 수정하면 가능은 하지만

폼메일 페이지 위치를  다른 곳으로 이동하고 작동시켜보세요

 

send.php 소스에 파일 저장위치에 대한 정보가 없는듯 싶은데, 그것도 확인해보세요

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 125,873
© SIRSOFT
현재 페이지 제일 처음으로