1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title></title>
5 </head>
6 <body>
7 <input type="file" multiple name="image[]" /> <br>
8 <input type="file" multiple name="image[]" /> <br>
9 <input type="file" multiple name="image[]" /> <br>
10 <input type="button" value="提交">
11 </body>
12 <script src="jquery.min.js"></script>
13 <script type="text/javascript">
14 $(':button').click(function() {
15 //formdata储存异步上传数据
16 var formData = new FormData();
17 formData.append('image[]',$(':file')[0].files[0]);
18 formData.append('image[]',$(':file')[1].files[0]);
19 formData.append('image[]',$(':file')[2].files[0]);
20
21 $.ajax({
22 url:"upload.php",
23 type: 'POST',
24 data: formData,
25 //这两个设置项必填
26 contentType: false,
27 processData: false,
28 success:function(data){
29 }
30 })
31 });
32 </script>
33 </html>
FormData使用详解