Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML PHP表单文件上传-在提交时显示文件名并将文件发送到电子邮件_Php_Html_Forms_Email_File Upload - Fatal编程技术网

HTML PHP表单文件上传-在提交时显示文件名并将文件发送到电子邮件

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

我有一个html表单我有一个文件上传按钮-它的工作文件上传到一个上传文件夹。我需要

  • 在提交时显示上传的文件名。应将其添加到此块中:

    <?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 } ?>
    
    
    

    名字:

    姓氏:

    电子邮件:

    主题:

    类型:

    上传:

此时print\u r显示文件,但在一个混乱的数组中,我需要清理它

  • 提交此表单后,发送的电子邮件中没有随附的文件。在发送电子邮件的部分中,我只有以下内容:

    //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计算出来了-谢谢你,威尔来看看这个教程。