当上传一个或两个图像时,它们存在于$ _FILES中,但是当有更多文件时,即使我可以在请求有效负载中看到图像,$ _FILES也是空的。这些图像不会超过几MB。
在php.ini中,max_filesize是64M,max_file_uploads是20.它工作了bofore,并且有一个原因我不记得我改变了php脚本而且它已经坏了。
表格:
<form id="new-post-form" name="new-post-form" enctype="multipart/form-data" method="POST">
<textarea name="new-post-text" id="new-post-text" placeholder="What's up?"></textarea>
<div id="new-post-image-container">
<input type="file" class="new-post-image" name="new-post-image[]" multiple>
</div>
<input type="button" name="post-submit" class="post-submit" value="Post">
</form>
Ajax请求:
var formData = new FormData($('form')[0]);
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
//Upload progress
xhr.upload.addEventListener('progress', function(event) {
if(event.lengthComputable) {
var percentComplete = event.loaded / event.total;
//do something with upload progress
}
}, false);
return xhr;
},
type: 'POST',
url: 'http://localhost/Traveler\'s Hut - Cijeli/public/new_post.php',
data: formData,
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
},
success: function(response) {
var data = JSON.parse(response);
}
});
var_dump($_FILES)
返回数组大小为0.
答案 0 :(得分:0)
问题出在php.ini中,post_max_size设置为3M,这对于我试图上传的内容还不够。