Small experience in swfupload

Source: Internet
Author: User
Tags mootools

SwfuploadIs a client file upload tool. If the traditional file upload method cannot meet your needs, try this.

Functions of swfupload:

  • You can select multiple files in the file selection dialog box (of course, you can also select multiple files)
  • You can set the file types and descriptions displayed in the upload dialog box.
  • No refreshing page upload (Post File data using Ajax)
  • Provides Event Callback of the upload progress to display the upload progress in real time (this is cool, so you do not need to frequently call the server code to obtain the upload progress)
  • Good browser compatibility
  • Uses namespaces to be compatible with other JS libraries (such as jquery, prototype, and so on)
  • Support for flash 8 and Flash 9 players

This is the help of swfupload in Chinese. Thanks to the hard work of the translator.

When I used swfupload for the first time, I found that it was in conflict with mootools version 1.10: When IE7 is refreshed or disabled, it will cause a swfupload component script error, and it will work normally after switching to the latest mootools.

Another problem is the session. In many cases, the code that receives File Upload data needs to process permissions based on the current session. There is no problem in IE. The session cannot be obtained in Firefox because Flash Processes cookies in a different way, in Firefox, swfupload cannot post the cookie information of the current user to the server. The solution is also relatively simple, that is, you can obtain the cookie information and upload it along with the file (Flash 9 supports. can directly reference global. asax provided by swfupload to process session information. You only need to add the following code when creating the swfupload object:

1 var swfu;
2 function initswfu ()
3 {
4 swfu = new swfupload ({
5 upload_url: "<% = page. resolveclienturl ("~ /Swfupload/upload. aspx ") %> ",
6 flash_url: "<% = page. resolveclienturl ("~ /Swfupload/swfupload_f9.swf ") %> ",
7 file_size_limit: "204800 ",
8 file_types: "*. rar; *. Zip ",
9 file_types_description: "package file ",
10 post_params :{
11 "aspsessid": "<% = session. sessionid %> ",
12 "authid": "<% = request. Cookies [formsauthentication. formscookiename]. Value %>"
13 },


The aspsessid is the user's sessionid, And the authid is the formsauthentication authentication information. If you do not need formsauthentication, you can remove 12 rows. Of course, if you need other custom information in the cookie, add and modify global here. asax.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.