我已經上傳的文件,現在我需要發送上傳的文件在郵件作爲attachment.Refer小提琴file upload。如何在郵寄此上傳作爲附件。如何使用jQuery發送上傳的文件在郵件作爲附件
HTML
<form id="myform" action="process-upload.php" method="post" enctype="multipart/form-data">
<input id="tele" type="file" name="filename"/>
<br/>
<input class="formbtn" type="submit" value="Upload" />
的jquery
$(文件)。就緒(函數(){
$('#myform').validate({
rules: {
filename: {
required: true,
extension: "docx|rtf|doc|pdf"
}
},
messages: {
filename: {
required: "Please upload resume",
extension: "Please upload valid file formats"
}
}
});
});
PHP
<?php
require("class.phpmailer.php");
$email = new PHPMailer();
$email->From = '[email protected]';
$email->FromName = 'Name';
$email->Subject = 'Subject';
$email->Body = 'Message Body';
$email->AddAddress('[email protected]');
$target_path = "uploads/";
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$email->AddAttachment(basename($target_path . $_FILES['uploadedfile']['name']));
return $email->Send();
?>
郵件代碼在哪裏? –
我沒有寫它yet.My本身的問題,只有如何發送此上傳的文件作爲附件 –
不是很困難task.try谷歌it.visit的電子郵件一些鏈接[http://webcheatsheet.com/php /send_email_text_html_attachment.php],[http://php.net/manual/en/function.mail.php] –