I. About UPLOADIFY
Uploadify is a jquery plugin that allows you to easily add multiple file uploads to your site. There are two different versions (HTML5 and Flash) that allow you to flexibly choose the right implementation for your website and fallback method to make it degrade gracefully.
Two. Problem sorting
Issue 1: the page report Plugin's picture cannot be found
In this case, it is clear that the path referenced in the relevant file is incorrect.
Locate the file below and modify the path to the correct path.
Issue 2: page report net::err_name_not_resolved
Find the file below.
Find in plugin main file
1 this. Settings.button_image_url=swfupload.completeurl (this. settings.button_image_url);
Change it to:
1 if (this. settings.button_image_url!= "") {2 this. Settings.button_image_url=swfupload.completeurl (this. Settings.button_image_url ); 3 }
Note: here to paste replication do not use the VS's Bring-your-own-replace feature to avoid replacing other code errors.
Question 3: Server Pass session
First add two get session method under Global.asax configuration file
Method 1:
1 protected voidApplication_BeginRequest (Objectsender, EventArgs e)2 {3 /*We guess at the "This" session is not a already retrieved by application so we recreate cookies with the session ID ... /c2>*/4 Try5 {6 stringSession_param_name ="Aspsessid";7 stringSession_cookie_name ="Asp.net_sessionid";8 9 if(Httpcontext.current.request.form[session_param_name]! =NULL)Ten { One Updatecookie (Session_cookie_name, Httpcontext.current.request.form[session_param_name]); A } - Else if(Httpcontext.current.request.querystring[session_param_name]! =NULL) - { the Updatecookie (Session_cookie_name, Httpcontext.current.request.querystring[session_param_name]); - } - } - Catch + { - } + A Try at { - stringAuth_param_name ="AUTHID"; - stringAuth_cookie_name =Formsauthentication.formscookiename; - - if(Httpcontext.current.request.form[auth_param_name]! =NULL) - { in Updatecookie (Auth_cookie_name, Httpcontext.current.request.form[auth_param_name]); - } to Else if(Httpcontext.current.request.querystring[auth_param_name]! =NULL) + { - Updatecookie (Auth_cookie_name, Httpcontext.current.request.querystring[auth_param_name]); the } * $ }Panax Notoginseng Catch - { the } +}
Method 2:
1 Private voidUpdatecookie (stringCookie_name,stringcookie_value)2 {3HttpCookie cookie =HttpContext.Current.Request.Cookies.Get (cookie_name);4 if(NULL==cookies)5 {6Cookie =NewHttpCookie (cookie_name);7 }8Cookies. Value =Cookie_value;9 HttpContext.Current.Request.Cookies.Set (cookie);Ten}
Add a value operation to the interface you are using, and add it to the top of the plugin (use the @ symbol in C # in the page and as a global variable in the JS code)
1 var auth = "@ (request.cookies[formsauthentication.formscookiename]==null? String. Empty:request.cookies[formsauthentication.formscookiename]. Value) "; 2 var Aspsessid = "@Session. SessionID";
Then write in the formdata of the plugin:
1 ' folder ': '/upload ', ' aspsessid ': aspsessid, ' AUTHID ': Auth
The whole effect is as follows:
1<link href= "~/content/uploadify/uploadify.css" rel= "stylesheet"/>2<script src= "~/content/uploadify/jquery.uploadify.min.js" ></script>3<script type= "Text/javascript" >4 //Upload Image5$(function () {6 varAuth = "@ (request.cookies[formsauthentication.formscookiename]==null? String. Empty:request.cookies[formsauthentication.formscookiename]. Value) ";7 varAspsessid = "@Session. SessionID";8$ ("#btnUpload"). uploadify ({9ButtonText: ' Upload image ',TenHeight:20, Onewidth:120, ASWF: '/content/uploadify/uploadify.swf ', -Uploader: '/back_areas/photoslider/upload ',//upload files to the server through a program in the background -Multifalse,//whether to allow multiple files to be selected at the same time theFilesizelimit: ' 8MB ',//File Size -Filetypeexts: ' *.gif;*.png;*.jpg;*jpeg ',//extension of the optional file - FormData: { -' Folder ': '/upload ', ' aspsessid ': aspsessid, ' AUTHID ': Auth//Test + }, -Onuploadsuccess:function(file, data, response) { + varJsondata =$.parsejson (data); A$.procajaxmsg (Jsondata,function () { at$.alertmsg (jsondata.msg, ' Operation Tips ',function () { -$ ("#uImgUrl"). attr ("src"), Jsondata.backurl); -$ ("#h_uImgUrl"). Val (jsondata.backurl); - }); -},function () { -$.alertmsg (jsondata.msg, ' Operation Tips ',NULL); in }); - }, toOnuploaderror:function(file, ErrorCode, ErrorMsg, errorstring) { +$.alertmsg (' file ' + file.name + ' upload failed: ' + errorstring, ' upload failed ',NULL); - }, theOnselecterror:function(file, ErrorCode, ErrorMsg, errorstring) { *$.alertmsg (' file ' + file.name + ' cannot be uploaded: ' + errorstring, ' select Invalid ',NULL); $ }Panax Notoginseng - }); the }); + A</script>
Solutions for uploading plugin-related issues in the "original" MVC project using jquery's upladify image