jquery uploadify solutions that can't be uploaded under Google and Firefox
First, jquery uploadify self Introduction:
(1), everyone good, I am a large family of jquery Plug-ins in charge of the implementation of asynchronous upload Plug-ins, I am not the only one, but better use of a section.
(2), my function:
Support single file or multiple file upload, can control the number of concurrent uploaded files
Support the use of various languages on the server side, such as PHP tutorials, ... net,java ...
Parameters can be configured to upload file types and size limits
Automatically upload by parameter to configure whether to select files
Easy to extend, can control the callback function of each step (onselect, OnCancel ...)
Controlling skins through interface parameters and CSS Tutorials
Uploadify Home Address: http://www.uploadify.com/on this page you can learn more about him.
(3), my usage:
Go to baidu.com,google.com Search search, a lot.
Second, Firefox under my fault, is my problem?
jquery uploadify in IE can be normal upload, in the implementation of asynchronous upload, each file in the upload will be submitted to the server a request. Each request requires security verification, session, and cookie validation. Yes, that's it. Since the jquery uploadify is to upload with the help of Flash, every time the data stream request is sent to the background, IE will automatically bundle the local cookie store together to send to the server. But Firefox and Chrome won't do it, and they'll think it's not safe. Ah, that's the reason.
To find out why, in letting us understand two concepts:
(1), Session:
The session, also known as conversation State, is the most commonly used state in the web system to maintain some information related to the current browser instance. For example, we can put the user name of the logged-in user in the session, so that we can judge a key in the session to determine whether the user is logged in, if the user name is how much.
We know that session for each client (or browser instance) is "hand in hand", the first time a user to connect with the Web server, the server will give users a sessionid as an identity. SessionID is a 24-character random string. Each time the user submits the page, the browser will include the SessionID in the HTTP header and submit it to the Web server so that the Web server can distinguish which client is the current request page. So, what are the storage SessionID patterns that the ASP tutorial. NET 2.0 offers?
(2), cookies, and sometimes their plural form cookies, are data (usually encrypted) that are stored on a user's local terminal in order to identify the user and perform session tracking.
Third, the solution
In the Global.asax file, write the following code:
void Application_BeginRequest (object sender, EventArgs e)
{
try {
String session_param_name = "ASPs Tutorial Essid";
String session_cookie_name = "asp.net tutorial _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 {
}
Here is authentication
try {
String auth_param_name = "Authid";
string auth_cookie_name = Formsauthentication.formscookiename;
if (Httpcontext.current.request.form[auth_param_name]!= null)
{
Updatecookie (Auth_cookie_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, String 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); or reset the cookie value in the request, assign the server-side session value to it
}
/*---------------------------aspx page end Code---------------------------------* *
This.hfauth.value = Request.cookies[formsauthentication.formscookiename] = = null? String.empty:request.cookies[formsauthentication.formscookiename].value;
This.hfaspsessid.value = Session.SessionID;
Save the session value and the authentication value to the client control, then you can get the two values through JS and pass to the plugin JS initialization program below.
(The reason why you chose to store the session value in the control is that the client is afraid of disabling cookies.) )
/*-----------------------------The following is a JS code----------------------------------* *
Initupload:function (auth, Aspsessid) {
$ ("#uploadify"). Uploadify ({
Uploader: ' scripts/jqueryplugins/infrastructure/uploadify.swf ',
Script: ' Handlers/resourcehandler.ashx?optype=uploadresource ',
Cancelimg: ' Scripts/jqueryplugins/infrastructure/cancel.png ',
Queueid: ' Filequeue ',
SizeLimit: ' 21480000000 ',
Wmode: ' Transparent ',
Fileext: ' *.zip,*.jpg, *.rar,*.doc,*.docx,*.xls,*.xlsx,*.png,*.pptx,*.ppt,*.pdf,*.swf,*.txt ',
Auto:false,
Multi:true,
Scriptdata: {aspsessid:aspsessid, Authid:auth},
...//More configuration items, you can view the official configuration document
When the plug-in is initialized, the locally recorded session value and the authentication value are passed to the initialization method for parameter assignment, so that the corresponding session value is included in the request file each time an asynchronous request uploads the file.