【发布时间】:2018-11-04 10:55:44
【问题描述】:
我有一个带有上传部分的表单。上传文件后,用户单击发送按钮。之后我想将文件作为附件发送到收件人邮件
【问题讨论】:
我有一个带有上传部分的表单。上传文件后,用户单击发送按钮。之后我想将文件作为附件发送到收件人邮件
【问题讨论】:
如果您的表单中有<input type='file' name='myFile' />,则在提交时,您只需在您的 php 文件中获取此命名字段
if( isset($_POST['myFile']) ){
// means there is file submitted
// do process it here (store, edit, delete, whatever)
}
【讨论】:
if( isset($_POST['myFile']) ){
$attachname8=$_FILES['myFile']['name'];
$attachment8='';
$output_dir="report/";
//Filter the file types , if you want.
if(!empty($attachname8))
{
if ($_FILES["myFile"]["name"] > 0)
{
echo "Error: " . $_FILES["myFile"]["error"] . "<br>";
}
else
{
//move the uploaded file to uploads folder;
move_uploaded_file($_FILES["myFile"] ["tmp_name"],$output_dir.$_FILES["myFile"]["name"]);
$attachment8="report/".$_FILES["myFile"]["name"];
}
}
}
【讨论】: