php 메일에 첨부파일 붙여 보내는 중에 질문하나 드려봅니다. 채택완료
===== PHP파일은 아래와 같습니다. =====
$headers .= "From :$name<$e_mail>\r\n";
$heasers .= "X-Mailer:PHP MAILER\r\n";
if($upfile && $upfile_size)
{
$filename=basename($upfile_name);
$result=fopen($upfile,"r");
$file=fread($result,$upfile_size);
fclose($result);
$upfile_type = "application/octet-stream";
$boundary = "--------". uniqid("part");
$headers .= "MIME-Version: 1.0 \r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
$body .= "This is a multi-part message in MIME format.\r\n\r\n";
$body .= "--$boundary\r\n";
$body .= "Content-Type: text/html; charset=euc-kr\r\n";
$body .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$body .= nl2br(stripslashes($contents))."\r\n\r\n";
$body .= nl2br(stripslashes($phpworld))."\r\n\r\n";
$body .= "--$boundary\r\n";
$body .= "Content-Type: $upfile_type; name=\"$filename\"\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= ereg_replace("(.{80})","\\1\r\n",base64_encode($file));
}
else
{
$body = stripslashes($contents). "\r\n\r\n";
}
mail("test@test.com",$subject,$contents,$headers);
?>
이렇게 소스를 작성하고요
sendmail.php 에서
if($_POST){
print_r($_POST);
}else{
echo 'post변수가없습니다.';
}
?>
이렇게 날려보면
Array ( [name] => 이름 [e_mail] => 이메일주소 [subject] => 제목 [contents] => 내용 [send] => 편지보내기 )
이렇게 날아오는데요.
왜 에서 파일첨부로 파일까지 넣어줬는데
sendmail 에선 파일내용을 못가져 올까요?
답변 1개
php에서 파일은 $_POST 가 아니고 $_FILES 에 담깁니다.
http://php.net/manual/kr/reserved.variables.files.php">http://php.net/manual/kr/reserved.variables.files.php
http://deuxism.tistory.com/22">http://deuxism.tistory.com/22
참고해보세요.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인