HTML PHP表单文件上传-在提交时显示文件名并将文件发送到电子邮件
我有一个html表单我有一个文件上传按钮-它的工作文件上传到一个上传文件夹。我需要HTML PHP表单文件上传-在提交时显示文件名并将文件发送到电子邮件,php,html,forms,email,file-upload,Php,Html,Forms,Email,File Upload,我有一个html表单我有一个文件上传按钮-它的工作文件上传到一个上传文件夹。我需要 在提交时显示上传的文件名。应将其添加到此块中: <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <div id="sadhu"> <p class="general_site">First Name:<strong><?php ec
- 在提交时显示上传的文件名。应将其添加到此块中:
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <div id="sadhu"> <p class="general_site">First Name:<strong><?php echo $firstname;?></strong></p> <p class="general_site">Last Name:<strong><?php echo $lastname;?></strong></p> <p class="general_site">Email:<strong><?php echo $email;?></strong></p> <p class="general_site">Theme:<strong><?php echo $theme;?></strong></p> <p class="general_site">Type:<strong><?php echo $type;?></strong></p> <p class="general_site">Upload:<strong><?php print_r($_FILES['datafile']);?></strong></p> </div> <?php } ?>
名字:
姓氏:
电子邮件:
主题:类型:
上传:
- 提交此表单后,发送的电子邮件中没有随附的文件。在发送电子邮件的部分中,我只有以下内容:
//If there is no error, send the email if(!isset($hasError)) { $emailTo = 'info@bgv.co.za'; //Put your own email address here $body = "First Name: $firstname \n\nLast Name: $lastname \n\nEmail: $email \n\nTheme: $theme \n\nType of Abstract: $type \n\nUpload: $datafile \n\n"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; }
//如果没有错误,请发送电子邮件 如果(!isset($hasError)){ $emailTo=info@bgv.co.za“;//在这里输入您自己的电子邮件地址 $body=“First Name:$firstname\n\n last Name:$lastname\n\nEmail:$email\n\n主题:$theme\n\n摘要类型:$type\n\nUpload:$datafile\n\n”; $headers='发件人:我的站点'。“\r\n.”回复:'.$email; 邮件($emailTo、$subject、$body、$headers); $emailSent=true; }
$\u文件['datafile']['name']
对于第二种情况,将文件附加到电子邮件有点棘手。看看这个,它在我刚开始的时候帮了我很多忙Hiya Bru:)太好了-我必须说我把$FILES计算出来了-谢谢你,威尔来看看这个教程。