<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>文件上传</title> </head> <body> <form id= "uploadForm"> <p >指定文件名: <input type="text" name="filename" value= ""/></p > <p >上传文件: <input type="file" name="file1" id="file1" multiple="multiple" /></p> <p >上传文件: <input type="file" name="file2" id="file2" /></p> <p >上传文件: <input type="file" name="file3" id="file3" /></p> <input type="button" value="上传" onclick="doUpload()" /> </form> <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="lib/layer/2.4/layer.js"></script> <script type="text/javascript" src="js/common.js"></script> <script type="text/javascript"> //获取token var token = parent.window.document.getElementById("token").value; function doUpload() { var formData = new FormData(); formData.append("token", token); formData.append("file1", $('#file1')[0].files[0]); formData.append("file2", $('#file2')[0].files[0]); formData.append("file3", $('#file3')[0].files[0]); $.ajax({ url: 'bookController/uploadMult' , type: 'post', data: formData, cache: false, processData: false, contentType: false, async: false }).done(function(res) { }).fail(function(res) { }); } </script> </body> </html>