actually save the picture in. NET MVC Maximum The problem is not how to save the picture. But authentication .
The biggest problem with Firefox and Chrome is that flash as Plugins appear. Thus formed two terminals.
in this case, different useragent use different Cookies .
SessionID is different, so as the session to verify the user's way, it seems that some is not feasible.
Well, look at the idea.
Modify the code for SessionID, in Global.asax
protected void Application_BeginRequest (object sender, EventArgs e) {try{string session_param_name = "Aspsessid"; string Session_cookie_name = "Asp.net_sessionid"; if (httpcontext.current.request.form[session_param_name]! = null) { Setcookie (Session_cookie_name, Httpcontext.current.request.form[session_param_name]);} else if (httpcontext.current.request.querystring[session_param_name]! = null) {Setcookie (Session_cookie_name, Httpcontext.current.request.querystring[session_param_name]);} String auth_param_name = "AUTHID"; string auth_cookie_name = Formsauthentication.formscookiename;if ( Httpcontext.current.request.form[auth_param_name]! = null) {Setcookie (Auth_cookie_name, Httpcontext.current.request.form[auth_param_name]);} else if (httpcontext.current.request.querystring[auth_param_name]! = null) {Setcookie (Auth_cookie_name, Httpcontext.current.request.querystring[auth_param_name]);}} catch{}}private void Setcookie (String cookie_name, String cookie_value) {HttpCookie cookie = HttpContext.Current.ReQuest. Cookies.get (Cookie_name); if (null = = cookie) {cookie = new HttpCookie (cookie_name);} Cookies. Value = Cookie_value; HttpContext.Current.Request.Cookies.Set (cookie);}
Accept Flash Upload Code
[Httppost]public jsonresult swfuploadimg () {try{//authentication if (session["auth"] = = null) {return Json (new {status = False, Msg = "You haven't logged in yet!" " });} Accept files HttpPostedFileBase file = request.files["Filedata"];//if the file is null if (file = = null) {return Json (new {status = False, MSG = "The upload file is empty!" " });} Whether the format is valid if (! Common.isauthorizedfile (file. FileName) {return Json (new {status = False, msg = "The upload file format is not valid!") " });} Check if (file. ContentLength >= config.picmaxsize) {return Json (new {status = False, msg = "Picture exceeds limit!) " });} File Rename string file_name = Common.getnewimgname (file. FileName);//Save picture file. SaveAs (Config.picpath + file_name);//Returns the result return Json (new {status = True, msg = "Upload succeeded!) ", filename = file_name});} catch (Exception ex) {return Json (new {status = False, msg = "Exception error"}); Common.Log ("Swfuploadimg", ex. Message);}}
The above is only my current use of the scheme, such as the existence of security loopholes, please also point out!
Flash implementation of ASP. NET MVC upload---Flash article
Flash implementation of ASP. NET MVC upload---.