Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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
使用以下jQuery脚本/PHP从网页发送附件。。。_Php_Jquery_Forms - Fatal编程技术网

使用以下jQuery脚本/PHP从网页发送附件。。。

使用以下jQuery脚本/PHP从网页发送附件。。。,php,jquery,forms,Php,Jquery,Forms,我有一个网站 这个页面的工作方式很棒。我可以填写所有字段,附上一份文档,点击发送,电子邮件就会发送 有一个JSFIDLE <td style="font-size: 22px; font-weight: bold; text-align: center;">Forms <br />you <br />want to <br />attach:</td>

我有一个网站

这个页面的工作方式很棒。我可以填写所有字段,附上一份文档,点击发送,电子邮件就会发送

有一个JSFIDLE

                    <td style="font-size: 22px; font-weight: bold; text-align: center;">Forms <br />you <br />want to <br />attach:</td>
                        <td style="padding-left: 20px;">
        <input name="fileAttach[]" type="file" class="multi"><br><br>
                        </td>
Forms
您希望
附加:

但是,我已经设置了另一个页面。这是我真正想要的

但是,在每个复选框后面,我希望有一个预定义的文档。某种附件

逻辑的工作原理如下…

  • 填写“收件人”框和“主题”
  • 选中必要的复选框
  • 点击“发送”按钮,电子邮件就会发出
  • 这个有一个JSFiddle

                        <td style="font-size: 22px; font-weight: bold; text-align: center;">Forms <br />you <br />want to <br />attach:</td>
                            <td style="padding-left: 20px;">
            <input name="fileAttach[]" type="file" class="multi"><br><br>
                            </td>
    
    这是其中的一些代码…

    </div><!-- Close Form Header -->
        <div class="form-column"><!-- Column -->
        <div class="form-label">Financial Aid Forms</div><!-- Label -->
            <div class="form-content"><!-- Content -->
                <ul>
                    <li><input name="fileAttach[]"  type="checkbox" class="multi">Finance Form 1</li><br />
                </ul>
           </div>
    
    
    财政援助表格
    
    • 财务表1

    我不知道如何配置复选框后面的文档。我只是想从服务器中提取文档

    我不确定如何在JSFIDLE中包含PHP文件,所以我在这里发布了与附件相关的部分

    <?
    $strTo = $_POST["txtTo"];
    $strSubject = $_POST["txtSubject"];
    $strMessage = nl2br($_POST["txtDescription"]);
    
    //*** Uniq id Session ***//
    $strSid = md5(uniqid(time()));
    
    $strHeader = "";
    $strHeader .= "From: ".$_POST["South University"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";
    
    $strHeader .= "MIME-Version: 1.0\n";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
    $strHeader .= "This is a multi-part message in MIME format.\n";
    
    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-type: text/html; charset=utf-8\n";
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
    $strHeader .= $strMessage."\n\n";
    
    //*** Attachment ***//
    for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
    {
    if($_FILES["fileAttach"]["name"][$i] != "")
    {
    $strFilesName = $_FILES["fileAttach"]["name"][$i];
    $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
    $strHeader .= "Content-Transfer-Encoding: base64\n";
    $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
    $strHeader .= $strContent."\n\n";
    }
    }
    
    $flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
    
    if($flgSend)
    {
    echo "Mail send completed.";
    }
    else
    {
    echo "Cannot send mail.";
    }
    ?>
    
    
    
    或者如果有更简单的方法,请告诉我。我仍然希望维护上述相同的功能