- Download ajaxfileupload.js (download URL: http://fileuploadajax.codeplex.com/downloads/get/20976)
- Modify Ajaxfileupload.js Internal Program
1 one, about 32 lines2Createuploadform:function(ID, fileelementid,data)3 Two, about 47 lines4JQuery (Form). AppendTo (' body '); Add the code before5 if(data) {6 for(varIinchdata) {7$ (' <input type= ' hidden "name=" ' + i + ' "value=" ' + data[i] + ' "/> '). AppendTo (form);8 }9 }Ten three, about 61 lines to modify One varform = Jquery.createuploadform (ID, s.fileelementid,s.data);
View Code
- The third step is to start calling the
1 functionFileUpload () {2 varJiangshi_name = $ ("#jiangshi_name"). Val ();3 varJiangshi_rongyu = $ ("#jiangshi_rongyu"). Val ();4 varJiangshi_xueli = $ ("#jiangshi_xueli"). Val ();5 $.ajaxfileupload ({6Type: "POST",7URL: "/ben/main_guanli.php",8 data: {9ETC: "TEACHERUPD",Ten Jiangshi_name:jiangshi_name, One Jiangshi_rongyu:jiangshi_rongyu, A Jiangshi_xueli:jiangshi_xueli - }, - //to be passed to the background parameters, no can not write theSecureuri:false,//whether to enable secure commit, default to False -Fileelementid: ' Doc ',//ID property of the File selection box -DataType: ' JSON ',//format returned by the server -Asyncfalse, +Successfunction(data) { - alert (data); + }, AErrorfunction(data, status, E) { atAlert ("Data Error") - }, - }); -}
View Code
Ajax asynchronous upload file data parameter----small Ha Co JS