Recently do the project encountered upload need to show the progress of the problem, through the uploadfiy very good to solve the problem but (IE9 there is a button can not click the problem, still can't find the good plan)
You need to download jquery.tmpl.min.js and reference under jquery when using the uploadfiy3.2 version
$ ("#uploadify"). Uploadify ({' Uploader ': '/lzks/handler/bigfileuploadhandler.ashx ', ' swf ': ' /lzks/scripts/uploadify/uploadify.swf ', ' cancelimage ': '/lzks/scripts/uploadify/cancel.png ', ' Queueid ': ' Filequeue ',//' auto ': false, ' multi ': true, ' buttontext ': ' File Upload ' , ' FormData ': {' aspsessid ': aspsessid, ' AUTHID ': auth}, ' OnSelect ': function (file) { $ (' #uploadify '). Uploadifysettings (' FormData ', {' Aspsessid ': aspsessid, ' AUTHID ': auth}); alert (formdate); }, ' OnComplete ': function (file, data, response) {}, ' Onqueuecomplete ': func tion () {alert ("Upload complete!) "); $ (' #fileQueue '). attr (' style ', ' Visibility:hidden '); }, ' Onselecterror ': function (file, ErrorCode, errormsg) {$ (' #fileQueue '). attr (' style ', ' Visibility:hidden '); }, ' Onuploadstart ': function (file) {$ (' #fileQueue '). attr (' style ', ' top:200px;left:400p X;width:400px;height:400px;visibility:visible '); } }); });
Upload with Uplodify There is also a small problem is that in the FF session will be lost, add the following code in the Gobal to the upload process defined session to the server
protected void Application_BeginRequest (object sender, EventArgs e) {/* We guess at the this point session Already retrieved by application so we recreate cookies with the session ID ... */try { String session_param_name = "Aspsessid"; String session_cookie_name = "Asp.net_sessionid"; if (httpcontext.current.request.form[session_param_name]! = null) {Updatecookie (session _cookie_name, Httpcontext.current.request.form[session_param_name]); } else if (httpcontext.current.request.querystring[session_param_name]! = null) { Updatecookie (Session_cookie_name, Httpcontext.current.request.querystring[session_param_name]); }} catch {} try {string Auth_param_nam E = "AUTHID"; String auth_cookie_name =Formsauthentication.formscookiename; if (httpcontext.current.request.form[auth_param_name]! = null) {Updatecookie (Auth_cooki E_name, Httpcontext.current.request.form[auth_param_name]); } else if (httpcontext.current.request.querystring[auth_param_name]! = null) { Updatecookie (Auth_cookie_name, Httpcontext.current.request.querystring[auth_param_name]); }} catch {}} private void Updatecookie (string cookie_name, St Ring cookie_value) {HttpCookie cookie = HttpContext.Current.Request.Cookies.Get (cookie_name); if (null = = cookie) {cookie = new HttpCookie (cookie_name); } cookie. Value = Cookie_value; HttpContext.Current.Request.Cookies.Set (cookie); }
Define the following two variables before JS loading
var auth = "<% = request.cookies[formsauthentication.formscookiename]==null?" String. Empty:request.cookies[formsauthentication.formscookiename]. Value%> "; var aspsessid = "<%= session.sessionid%>";
The handler file code is as follows: public class Bigfileuploadhandler:ihttphandler, irequiressessionstate {dalfile fdal = new DAL File (); public void ProcessRequest (HttpContext context) {context. Response.ContentType = "Text/plain"; Videoupload (context, Clsoft. Web.LZKS.Edu.Globe.filename); } public void Videoupload (HttpContext context, string filefoldername) {context. Response.Charset = "Utf-8"; String Aaaaaaa=context. request.querystring["SessionID"]; Httppostedfile file = context. request.files["Filedata"]; String uploadpath = HttpContext.Current.Server.MapPath (Uploadfilecommon.createdir (filefoldername)); if (file! = null) {if (! Directory.Exists (Uploadpath)) {directory.createdirectory (Uploadpath); } model.modelfile Model = new Model.modelfile (); Model. file_id = Guid.NewGuid (). ToString (); Model. file_name = file. FileName; Model. File_path = Uploadfilecommon.createdir (filefoldername); Model. file_size = file. ContentLength; Model. file_extension = file. Filename.substring (file. Filename.lastindexof ('. ') + 1); Model. File_date = DateTime.Now; Model. File_currentman = Clsoft. Web.LZKS.Edu.Globe.name; File. SaveAs (Uploadpath + model. file_name); list<model.modelfile> list = null; if (context. session["File"] = = null) {list = new list<model.modelfile> (); } else {list = context. session["File"] as list<model.modelfile>; } list. ADD (model); Context. Session.add ("File", list); } else {context. Response.Write ("0"); } }//The function of this code is to save the information of multiple files to the context. session["File"] as list<model.modelfilemodel.modelfile> for file information class
Implement bulk upload of information to session
3.2 Version Uploadify detailed examples (including FF and IE session issues)