【发布时间】:2015-03-12 06:21:37
【问题描述】:
html 标记:
<input id="fileSelect" type="file" id="file" name="files[]" multiple="multiple" accept="image/*" />
我正在使用 php.ini 上传多个文件。我想制作一组上传文件并使用ajax发送到服务器。如何将多个选中的文件组成一个数组?
JavaScript:
jQuery.ajax({
url: 'insertfiles.php',
type: "POST",
data: {
file: // array of selected files.
},
success: function(data){
},
error: function(data){
alert( 'Sorry.' );
}
});
【问题讨论】:
-
使用 ajax 发送文件的唯一方法是使用
FormData,参见THIS
标签: javascript php jquery ajax