폼메일 문의 만들었는데 파일 첨부가 안됩니다. 채택완료
견적문의 만들었습니다.
폼 내용은 잘 나가는데 파일 첨부에서 에러가 납니다. 메일 받아보면 파일만 안 들어옵니다.
에러코드 보니 다음 부분에서 에러가 나는 거 같은데 원인이 뭔지 모르겠습니다.
동일 서버에 설치된 그누4에서 잘 되는데 5에선 안되네요 ㅠㅠ
$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']);
폼메일 코드는 대충..
</span> </p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"><?php</span></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">include_once('./_common.php');</span></font></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">$g5['title'] = '견적문의';</span> </p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">include_once('./_head.php');</span></font></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">?></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"><form name="fformmail" action="sendform.php" method="post" enctype="multipart/form-data"></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"><label for="mb_name">고객성명<strong class="sound_only">필수</strong></label></span><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; color: rgb(0, 0, 0);"><input type="text" name="mb_name" id="mb_name" required class="frm_input required" size="30" value="<?php if($member['mb_level'] >= '2'){ ?><?php echo get_text($member['mb_name']) ?> (ID: <?php echo $member['mb_id'] ?>)<?php } ?>" /></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"><label for="company">회사명 / 근무처</label></span></p><p><span style="font-size: 11pt; line-height: 1.5;"><input type="text" name="company" class="frm_input" size="30" /></span></p><p><span style="font-size: 11pt; line-height: 1.5;">.</span></p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p><span style="font-size: 11pt; line-height: 1.5;"><label for="file1">Attachments (첨부파일) 1</label></span></p><p><span style="font-size: 11pt; line-height: 1.5;"><input type="file" name="file1" id="file1" class="frm_input"></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"><label for="file2">Attachments (첨부파일) 2</label></span><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; color: rgb(0, 0, 0);"><input type="file" name="file2" id="file2" class="frm_input"></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"><input type=image id="btn_submit" src="send.gif" border="0"></span></p><p><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"></form></span></p><p><font color="#3c3f45" style="font-size: 11pt; line-height: 1.5;"><span style="font-size: 11pt; color: rgb(0, 0, 0);">
</span></font></p><p><font color="#3c3f45" style="font-size: 11pt; line-height: 1.5;"><span style="font-size: 11pt; color: rgb(0, 0, 0);"><?php </span></font><span style="font-size: 11pt; line-height: 1.5;">include_once('./_tail.php'); </span><span style="font-size: 11pt; line-height: 1.5;">?></span></p><p><span style="font-family: 돋움, Dotum, sans-serif; font-size: 11pt; letter-spacing: -0.01px; line-height: normal;">
메일발송 코드 / sendform.php
</span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">include_once('./_common.php');</span><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">include_once(G5_LIB_PATH.'/mailer.lib.php');</span></font></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">if(empty($_POST["mb_name"])){</span></font></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span>alert("필수값이 넘어오지 않았습니다.\\n\\n다시 확인하십시오.");</span></font><span style="font-size: 11pt; line-height: 1.5;"> </span></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">}</span></font></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif" style="font-size: 11pt; line-height: 1.5;"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">
</span></font></p><p><font color="#3c3f45" face="돋움, Dotum, sans-serif" style="font-size: 11pt; line-height: 1.5;"><span style="letter-spacing: -0.01px; line-height: normal; font-size: 11pt; color: rgb(0, 0, 0);">w</span></font><span style="font-size: 11pt; font-family: 돋움, Dotum, sans-serif; letter-spacing: -0.01px; line-height: normal;">hile(list($key,$val) = each($_POST)){</span></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span>if($key == "faction" || $key == "x" || $key == "y") continue;</span></font></p><p><span class="Apple-tab-span" style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif; white-space: pre;"> </span><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">$arrkey[] = $key;</span> </p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span>$arrval[] = $val;</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">}</span></font></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"> </span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">$file = array();</span></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">for ($i=1; $i<=$attach; $i++) {</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"> if ($_FILES['file'.$i]['name'])</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"> $file[] = attach_file($_FILES['file'.$i]['name'], $_FILES['file'.$i]['tmp_name']);</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">
</span></font></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">$subject = $_POST["mb_name"] . " 님의 견적문의 폼메일";</span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"> </span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">$admin = get_admin('super');</span> </p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"> </span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">ob_start();</span> </p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">include "./post.php";</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">$content = ob_get_contents();</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">ob_end_clean();</span></font></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"> </span></p><p><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;">mailer($_POST["mb_name"], $_POST["mb_email"], "수신이메일", $subject, $content, 1, $file); </span><span class="Apple-tab-span" style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif; white-space: pre;"> </span> </p><p><span style="color: rgb(0, 0, 0); font-family: 돋움, Dotum, sans-serif; font-size: 11pt; letter-spacing: -0.01px; line-height: normal;">
실제 메일전송 코드 / post.php
</span></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif" style="font-size: 11pt; line-height: 1.5;"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><html></span></font><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"><head></span></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><meta http-equiv="content-type" content="text/html; charset=utf-8"></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><title>[<?=$subject?>]</title></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"></head></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><style></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">body, th, td, form, input, select, text, textarea, caption { font-size: 12px; font-family:sans-serif;}</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);">.line {border: 1px solid #868F98;}</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"></style></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><body leftmargin=0 topmargin=10 marginwidth=0 marginheight=0></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><table width="95%" cellpadding=5 cellspacing=0 border=1 align="center"></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><col width="20%" bgcolor="#eaeaea" style="font:bold;"></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><col width=""></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><tr></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span><td colspan=2 height=40 bgcolor="#ffffff"></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span> <?=$subject?></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span></td></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"></tr></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><? for($i=0;$i<count($arrkey);$i++){ ?></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><tr></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span><td><?=$arrkey[$i]?></td></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre; font-size: 11pt; color: rgb(0, 0, 0);"> </span><td><?echo str_replace("\r\n","
",stripslashes($arrval[$i]));?></td></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"></tr></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"><?}?></span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; color: rgb(0, 0, 0);"></table></span></font><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"></body></span><span style="font-size: 11pt; letter-spacing: -0.01px; line-height: normal; font-family: 돋움, Dotum, sans-serif;"></html></span></p><p><span style="color: rgb(0, 0, 0); font-family: 돋움, Dotum, sans-serif; font-size: 11pt; letter-spacing: -0.01px; line-height: normal;">
답변 2개
다시 확인해 보니 한가지 빠진 것 같아 보입니다.
폼메일 코드에서
<form name="fformmail" action="sendform.php" method="post" enctype="multipart/form-data">
부분 다음에
<input type="hidden" name="attach" value="2">
이 소스를 추가하셔야 attach 값을 가져올 것 같네요. value값이 2인 것은 첨부파일이 2개 이기에 그렇구요.
이게 빠졌으면 그누보드 4소스에서도 안되었을텐데요??? 거기는 있는 소스인데 그누5로 변경하면서 빼 먹은게 아닌가 추측해 보고요.
post.php파일에서도 그누5는 html5 버전이므로
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<html>
<head>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
for ($i=1; $i<=$attach; $i++) 에서 에러가 난다고 하셨는데
변수 i가 1부터 변수 attach값까지 for문으로 반복하는 구문인데
현재 위의 소스상에서는 변수 attach($attach) 에 대한 변수값이 없네요...?
이것부터 확인을 해보세요. 변수값이 없으니 에러가 날것 같은데요...
답변에 대한 댓글 1개
이렇게 바꿔봐도 안되는군요.. 이 코드로 그누4 에선 아주 잘 됩니다 ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
아무리 해봐도 파일 첨부가 안되네요.. 텍스트는 정상적으로 발송/수신 됩니다.
그누5 기본 폼메일(사이드뷰)로 테스트 해봤는데 역시 발송 안되는게 뭐 다른 문제가 있는듯 합니다.
이상한건 같은 서버에 설치된 그누/영카트4에선 아~~~주 ㅠㅠ 잘 된다는게 이해 안되네요.