PHP表单没有POST文件

时间:2015-03-31 15:39:28

标签: php file post

好的,所以我知道在这个主题上已经有很多问题,但他们的解决方案都没有对我有用。我已经验证file_uploads已打开,并且我的文件未超过文件max。当我提交表单时,POST数据包含除文件字段之外的所有内容,我无法弄清楚原因。我从PHP脚本获得的响应也不包括文件数组长度的值1,并且不包括用于成功移动文件的1。似乎文件从未发布过。我的想法已经不多了,非常感谢任何帮助。

HTML:

  <form enctype="multipart/form-data" action="/RK/submitQuestion.php" method="post">
    <table>
      <tr>
        <td>
          <h2>Personal Info</h2>
        </td>
      </tr>

      <tr>
        <td>First Name:</td>

        <td><input type="text" id="submitFirstName" name="submitFirstName" /></td>
      </tr>

      <tr>
        <td>Last Name:</td>

        <td><input type="text" id="submitLastName" name="submitLastName" /></td>
      </tr>

      <tr>
        <td>Email:</td>

        <td><input type="text" id="submitEmail" name="submitEmail" /></td>
      </tr>

      <tr>
        <td>
          <h2>Question</h2>
        </td>
      </tr>

      <tr>
        <td>Please enter your question here:</td>

        <td>
        <textarea name="submitComments" style="resize: none;" rows="5">
</textarea></td>
      </tr>

      <tr>
        <td>Attachment:</td>

        <td><input type="file" id="submitUserFiles" name="submitUserFiles" multiple=
        "multiple" /></td>
      </tr>

      <tr>
        <td><input type="submit" /></td>
      </tr>
    </table>
  </form>

PHP:

<?php
if (array_key_exists('submitUserFiles', $_FILES)) {
    //Loop through each file adding its location to an array
    $len = count($_FILES['submitUserFiles']['name']);
    echo $len;
    for ($i = 0; $i < $len; $i++) {
        $tmp_name = $_FILES['submitUserFiles']['tmp_name'];
        $name     = $_FILES['submitUserFiles']['name'];
        echo move_uploaded_file($tmp_name, 'C:\\inetpub\\wwwroot\\uploads\\' . $name);
        $mail->addAttachment('C:\\inetpub\\wwwroot\\uploads\\' . $name);
    }
}
if (!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    exit;
} else {
    echo 'Thank you for your question. Your message has been sent. Redirecting you back to where you were.';
}
?>

POST数据:

POST Data Screen

PHP响应:

Thank you for your question. Your message has been sent. Redirecting you back to where you were.

我期待看到的是:

11Thank you for your question. Your message has been sent. Redirecting you back to where you were.

0 个答案:

没有答案