Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.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
Javascript 通过AJAX将数据发布到PHP文件_Javascript_Php_Ajax - Fatal编程技术网

Javascript 通过AJAX将数据发布到PHP文件

Javascript 通过AJAX将数据发布到PHP文件,javascript,php,ajax,Javascript,Php,Ajax,我有一个可接受多个文件的输入: <input id="propertyImages" type="file" name="submission_img[]" multiple accept=".jpg, .jpeg, .png, .gif"/> 然后,我通过JS/Ajax将这些数据发布到PHP文件中: //Compiling the data which will be POSTed using AJAX. Note that the input above with id o

我有一个可接受多个文件的输入:

<input id="propertyImages" type="file" name="submission_img[]" multiple accept=".jpg, .jpeg, .png, .gif"/>

然后,我通过JS/Ajax将这些数据发布到PHP文件中:

//Compiling the data which will be POSTed using AJAX. Note that the input above with id of propertyImages is not part of the form with id accommodationForm and is therefore appended to the formData.
var form = $("#accommodationForm")[0]; 
var formData = new FormData(form);

var propertyImages = document.getElementById("propertyImages");

for(var i=0; i<propertyImages.files.length; i++){
   formData.append('propImages[]', propertyImages.files[i]);
}

//Printing to console the formData entries to confirm the formData data:
for (var d of formData.entries()) {
   console.log(d);
}

//The partial code for the ajax call:
$.ajax({
   url: "includes/handlers/ajax_submit_accommodation.php",
   method: "POST",
   data: formData,
...
//编译将使用AJAX发布的数据。请注意,上面id为propertyImages的输入不是id为AccountationForm的表单的一部分,因此会附加到formData。
变量形式=$(“#调节形式”)[0];
var formData=新formData(表格);
var propertyImages=document.getElementById(“propertyImages”);
对于(var i=0;i请查看指令:

max\u文件上传integer

允许同时上载的最大文件数

如“文件上传”部分的表格所示,默认值为20:

Name              Default   Changeable       Changelog
...
max_file_uploads  20        PHP_INI_SYSTEM   Available since PHP 5.2.12.
您需要更新
php.ini
中的该值

同时检查您是否超过或超过
.

尝试将尺寸检查的
if
!=0
更改为
!==0
>0
。是否从
$output
中得到不同的结果?我感觉不使用显式比较器(即
!==0
)会得到不真实的值;
Name              Default   Changeable       Changelog
...
max_file_uploads  20        PHP_INI_SYSTEM   Available since PHP 5.2.12.