即使通过线路发送数据,我的$ _FILES数组也是空的

时间:2015-02-03 13:54:34

标签: php file-upload

我有以下表格......

<form class="clearfix" action="/application_submit.php" method="post" enctype="multipart/form-data" name="applicationForm" id="applicationForm">

    <!-- 100 text/select/option inputs or so that I won't include here... -->

    <div class="line">
      <div class="unit size1of1">
        <label class="field_label" for="freeform_application_attachments">Attachments</label>
        <input type="file" name="file_attachments_1" value="" id="freeform_application_attachments0"  /><br/>
        <input type="file" name="file_attachments_2" value="" id="freeform_application_attachments1"  /><br/>
        <input type="file" name="file_attachments_3" value="" id="freeform_application_attachments2"  /><br/>
        <input type="file" name="file_attachments_4" value="" id="freeform_application_attachments3"  /><br/>
        <input type="file" name="file_attachments_5" value="" id="freeform_application_attachments4"  />
      </div>
    </div>
</form>

我提交JS ......

        $('form#applicationForm').validate({
          onkeyup: false,
          onfocusout: false,
          onclick: false,
          submitHandler: function(form) {
            form.submit();
          }
        });

最后,在我的网络标签中通过网络发送的内容标题(在此示例中,我只放入2个文件):

------WebKitFormBoundaryT5oEIdNCfF7vnxWr
Content-Disposition: form-data; name="file_attachments_1"; filename="lemonone-715d1576013f3260da2afa15a3ce26f03bacac72.zip"
Content-Type: application/zip


------WebKitFormBoundaryT5oEIdNCfF7vnxWr
Content-Disposition: form-data; name="file_attachments_2"; filename="browser   marklet.psd"
Content-Type: image/vnd.adobe.photoshop


------WebKitFormBoundaryT5oEIdNCfF7vnxWr
Content-Disposition: form-data; name="file_attachments_3"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryT5oEIdNCfF7vnxWr
Content-Disposition: form-data; name="file_attachments_4"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryT5oEIdNCfF7vnxWr
Content-Disposition: form-data; name="file_attachments_5"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryT5oEIdNCfF7vnxWr--

但在我的服务器上,这是我得到的......

Output

这是由此代码生成的......

echo "\$_FILES array:<br />";
var_dump($_FILES);

所以我有enctype="multipart/form-data",我有method="POST",我的所有文件输入都有名称,我的网络标签中的HTTP POST表示请求包含的文件是上传 - 但仍然$_FILES数组在服务器端是空的?

发生了什么事?

2 个答案:

答案 0 :(得分:1)

在这里,您可以找到使用PHP上传文件的清单:https://stackoverflow.com/a/3587158/1439906

也许你在php.ini中遗漏了一些东西,数据被发送但是PHP忽略了它。特别是,您应首先检查以下设置:file_uploads = Onpost_max_sizeupload_max_file_size。此类设置也可以在.htaccess文件中更改:请记住也检查它们。

答案 1 :(得分:0)

打开你的php.ini文件并查找file_uploads确保它已开启, file_uploads = On