Php $\u文件为空,$\u POST为空数组

Php $\u文件为空,$\u POST为空数组,php,jquery,ajax,.htaccess,file-upload,Php,Jquery,Ajax,.htaccess,File Upload,我正在尝试ajax文件上传。我在另一个项目中尝试过同样的脚本。它工作正常。但现在它不起作用了。在服务器端,我通过var\u dump($\u FILES[“uploadFiles”])得到“Null”和 var_dump($_POST[“uploadFiles]”)返回空数组:数组(1){[0]=>string(0)“} 因此,我怀疑apache/php配置存在一些问题 给出的一个解决方案讨论了htaccess重定向规则。以下是我的htaccess内容: # BEGIN WordPress &l

我正在尝试ajax文件上传。我在另一个项目中尝试过同样的脚本。它工作正常。但现在它不起作用了。在服务器端,我通过
var\u dump($\u FILES[“uploadFiles”])得到“Null”
var_dump($_POST[“uploadFiles]”)返回空数组:数组(1){[0]=>string(0)“}

因此,我怀疑apache/php配置存在一些问题

给出的一个解决方案讨论了htaccess重定向规则。以下是我的htaccess内容:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress</code>
提前感谢你的帮助

更新:

浏览器中的响应标题:

这是我的密码:

  <form class="inputF" id="entry_upload_form" action="" method="post" enctype="multipart/form-data">

        <div class="field_text">
         Attach file:  
        </div>
        <input type="file" name="file1[]" id="file1"> <br>

        <div class="field_text">
         Attach file:  
        </div>
        <input type="file" name="file2[]" id="file2"> <br>

        <div class="field_text">
         Attach file:  
        </div>
        <input type="file" name="file3[]" id="file3"> <br>

        <div class="buttonRow">
          <button class="submit buttons greenButton">Post</button> 
          <button class="reset buttons blueButton">Reset</button>
        </div>
  </form>

附加文件:

附加文件:
附加文件:
邮递 重置
我的jQuery的一部分:

var fileSelect = document.getElementById('file1');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    fileSelect = document.getElementById('file2');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    fileSelect = document.getElementById('file3');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    // Create a new FormData object.
    var formData = new FormData();

    // Loop through each of the selected files.
    for (var i = 0; i < files.length; i++) {
      var file = files[i];

      // Add the file to the request.
      formData.append('uploadFiles[]', file, file.name);
    }

    jQuery.ajax({
        url: content_url + '/themes/Karma/entry-portal/ajax_upload.php',  //Server script to process data
        type: 'POST',
        xhr: function() {  // Custom XMLHttpRequest
            var myXhr = jQuery.ajaxSettings.xhr();
            if(myXhr.upload){ // Check if upload property exists
                myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
            }
            return myXhr;
        },
        //Ajax events
        beforeSend: function () {
                //jQuery("#wpboulevard_progressBar").show();
            },
        success: function (response) {
                //jQuery('#wpboulevard_upload_status').html(response);
            },
                //error: errorHandler,
        // Form data
        data: formData,
        //Options to tell jQuery not to process data or worry about content-type.
        cache: false,
        contentType: false,
        processData: false
    });

    return false;
//On success
    function completeHandler(){
        jQuery().html('Files uploaded successfully');
    }

    //Progress handling function
    function progressHandlingFunction(e){
        if(e.lengthComputable){
            jQuery('progress').attr({value:e.loaded,max:e.total});
        }
    }
});
var fileSelect=document.getElementById('file1');
files1=fileSelect.files;
如果(files1.length!=0){
files[i]=fileSelect.files;
i++;
}
fileSelect=document.getElementById('file2');
files1=fileSelect.files;
如果(files1.length!=0){
files[i]=fileSelect.files;
i++;
}
fileSelect=document.getElementById('file3');
files1=fileSelect.files;
如果(files1.length!=0){
files[i]=fileSelect.files;
i++;
}
//创建一个新的FormData对象。
var formData=new formData();
//循环浏览每个选定文件。
对于(var i=0;i
将您的HTML更改为:

<form class="inputF" id="entry_upload_form" enctype="multipart/form-data">
        <div class="field_text">Attach file:</div>
        <input type="file" name="files[]" id="myFiles" multiple> <br>

        <div class="buttonRow">
          <button class="submit buttons greenButton">Post</button> 
          <button class="reset buttons blueButton">Reset</button>
        </div>
  </form>
对此:

var formData = new FormData();
// Loop through each file attached for upload and append it to formData
$.each($('#myFiles')[0].files, function(i, file) {
    formData.append('uploadFiles['+i+']', file);
});

日志中没有错误或警告/tmp文件夹是否可访问?下面是一个很好的检查列表:您是否在浏览器控制台中查看了请求/响应?尝试了
formData.append('uploadFiles',file)
而不是
formData.append('uploadFiles[],file,file.name)?请参阅@JayBlanchard,我添加了来自浏览器控制台的响应。看起来还行。144字节,在屏幕截图中看不到任何请求负载。我认为这个问题与客户端JS有关。
    var fileSelect = document.getElementById('file1');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    fileSelect = document.getElementById('file2');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    fileSelect = document.getElementById('file3');
    files1 = fileSelect.files;

    if(files1.length != 0) {
        files[i] = fileSelect.files;
        i++;
    }

    // Create a new FormData object.
    var formData = new FormData();

    // Loop through each of the selected files.
    for (var i = 0; i < files.length; i++) {
      var file = files[i];

      // Add the file to the request.
      formData.append('uploadFiles[]', file, file.name);
    }
var formData = new FormData();
// Loop through each file attached for upload and append it to formData
$.each($('#myFiles')[0].files, function(i, file) {
    formData.append('uploadFiles['+i+']', file);
});