사용자가 선택한 첨부 파일을 html 양식 (예 : pdf 파일)에서 보내 전자 메일로 보내려합니다.첨부 파일을 PHPMailer를 사용하여 양식으로 업로드
메일을 통해 모든 의견을 보낼 수 있지만 첨부 파일을 보내 주시면 도움을받을 수 있습니다. 도움을 주시면 감사하겠습니다. 여기에 (난 그냥 필요한 라인을 업로드하고있어) 내 코드
<label>Mail : </label>
<input name="email" type="text" placeholder="mail adress">
<div class="box">
<input type="file" name="file" id="file" class="inputfile inputfile-5" />
</div>
그리고 내 폼 handler.php : 당신이 첨부 파일이 어디 있는지 찾을 필요가
<?php
$file = $_POST['file'];
$email = $_POST['email'];
require $_SERVER["DOCUMENT_ROOT"] . '/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = '*****';
$mail->SMTPAuth = true;
$mail->Username = '****';
$mail->Password = '****';
$mail->From = $email;
$mail->SMTPSecure = 'tls';
$mail->Port = ****;
$mail->setFrom('*****', '*****');
$mail->addAddress('*****', '*****');
$mail->Subject = utf8_decode("Thank you for signing up");
$mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
$mail->Body = ($file);
//$mail->AltBody = utf8_decode($file);
if (!$mail->Send()) {
echo "error. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "mail sent";
?>
파일을 업로드하고 있습니까? $ _FILES [ 'file'] [ 'tmp_name']을 echo하면 어떤 결과가 나옵니까? –
나는 아무것도 얻지 못하고있다, 공백이다! 오류 없음! –
그러면 파일이 업로드되지 않습니다. 파일을 업로드 한 다음 파일에 경로를 추가 한 다음 첨부 파일에 경로를 추가하십시오. –