This article found that someone sent a short message to ask a question. I want to edit it today.
At the time of posting, there were still few articles about flash file submission on the Internet. Now it's a Google pull. So this article will not update anything ..
In addition, the example is a long time ago. It is not applicable to flash 10 and can only be used in versions earlier than Flash 9, if you want to see the effect, you can return the Flash version of the Local Machine to 9 and check the effect.
==================================================================== ====================
In a web enterprise project just a few weeks ago, you must have the batch upload function, and specify that the file upload function is the same as that of the old system (the old system is a C/S structure, ). There is no way to do it. If you want to do it only through flash, you can find something on the internet, and find this stuff-swfupload.
Official website address is: http://swfupload.mammon.se/
The examples on the official website only include PHP, C #, VB.net, and ror. Then I searched javaeye, as if there were not many, but only one article, which is also relatively advanced, so I can only do it myself.
After that, I thought it was really good and I felt very good at using it. I guess it may be useful for projects in the future.
I made a war package by myself. In a simple example, I passed the test in tomcat5.5 and java5.0 environments.
The package structure is as follows: Java code
- Index. jsp
- Upload. jsp
- JS
- + ----- Example_callbacks.js
- + ----- Swfupload. js
- Certificate -----swfupload.swf
Bytes
The above index. jsp is the file upload display page. Upload. jsp is used for the upload function. Two callback functions in JS are used to communicate with SwF, and the other one is the JS file used by itself.
The most important part is the following Java code in index. jsp:
- VaR swfu;
- Window. onload = function (){
- Swfu = new swfupload ({
- Upload_script: "../upload. jsp", // call the upload function
- Target: "swfuploadtarget ",
- Flash_path: "JS/swfupload.swf", // location of Flash
- Allowed_filesize: 30720, // 30 mb
- Allowed_filetypes :"*.*",
- Allowed_filetypes_description: "All files ...",
- Browse_link_innerhtml: "select ",
- Upload_link_innerhtml: "Start upload ",
- Browse_link_class: "swfuploadbtn browsebtn ",
- Upload_link_class: "swfuploadbtn uploadbtn ",
- Flash_loaded_callback: 'swfu. flashloaded ',
- Upload_file_queued_callback: "filequeued ",
- Upload_file_start_callback: 'uploadfilestart ',
- Upload_progress_callback: 'uploadprogress ',
- Upload_file_complete_callback: 'uploadfilecomplete ',
- Upload_file_cancel_callback: 'uploadfilecanceled ',
- Upload_queue_complete_callback: 'uploadqueuecomplete ',
- Upload_error_callback: 'uploaderror ',
- Upload_cancel_callback: 'uploadcancel ',
- Auto_upload: false
- })
- }
VaR swfu; window. onload = function () {swfu = new swfupload ({upload_script :".. /upload. JSP ", // call the upload function target:" swfuploadtarget ", flash_path:" JS/swfupload.swf ", // allowed_filesize: 30720, // 30 mballowed_filetypes :"*. * ", allowed_filetypes_description:" All files... ", steps:" select ", steps:" Start upload ", browse_link_class:" swfuploadbtn browsebtn ", upload_link_class:" swfuploadbtn uploadbtn ", flash_loaded_callback: 'swfu. flashloaded ', encoding: "filequeued", encoding: 'uploadfilestart', encoding: 'uploadprogress', encoding: 'uploadfilecomplete', encoding: 'uploadfilecanceled', encoding: 'uploadqueuecomplete ', upload_error_callback: 'uploaderror', upload_cancel_callback: 'uploadcancel', auto_upload: false })}
Note that this upload_script attribute is a relative address, which is the path of the SWF file relative to the upload function file. This is easy to make a mistake. In my package, upload. jsp is the upload function. You can see the code and upload a very original file.
In addition, if a 404 error occurs during the upload process, it is generally because the upload_script attribute is set incorrectly. If a 500 error occurs, it is an upload file (upload. jsp) error.
For more information, see the forum on the official website.