To use uplaodify3.1, naturally to download the appropriate package, http://www.uploadify.com/download/, here are two kinds of packages, one is based on flash, free, one is based on HTML5, need to pay, I said here is also the former. Of course, it's probably no longer the 3.1 version, which is estimated to be 3.2. However, the difference is not too big!
First introduce the file in the page:
<link rel="stylesheet"Type="Text/css"href="Css/uploadify.css"> <script type="Text/javascript"Src="Js/jquery-1.4.4.js"></script> <script type="Text/javascript"Src="Js/jquery.uploadify-3.1.js"></script> <script type="Text/javascript"Src="Js/jquery.uploadify-3.1.min.js"></script>
Uploadify.swf want to put together with CSS, otherwise will not find.
JSP page:
<input type="file" name="uploadify" id= " Uploadify "value=" browse "/><div id="filequeue " style="Border-top:thin solid gray; "></div>
Here is the code for my own page:
<script type="Text/javascript"> $('#rightFrame'). Load (function () {varAccount = $ ("#account"). Val (); varId= $ ("#userId"). Val (); varCurrentnode=0; $("#uploadify"). uploadify ({//Note: Here uploadify is HTML tag, file input box IDSwf:'css/uploadify.swf', uploader:'uploadfile.action;', cancelimg:'/images/uploadify-cancel.png', ButtonText:'Select File', Fileobjname:'uploadify', Auto:true, Multi:true, Debug:true, Queueid:'Filequeue',//here Filequeue which Div is displayed for the upload progress barformdata:{' Account': Account,'ID': ID,'CurrentNode':$("#rightFrame"). Contents (). Find ("#test"). Val ()}, removecompleted:true, Queuesizelimit:999, Filesizelimit:'100MB', Height: -, Width: -, Successtimeout: -, Requeueerrors:true, Uploadlimit:5, onuploadsuccess:function (file, data, response) {if(response) {CurrentNode=data; }}, Onqueuecomplete:function (stats) {window.parent.rightframe.location.href< /c2>="fileaction?filenode="+CurrentNode; Alert ("Upload Complete"); } }); }); </script>
Attribute Explanation:
Auto |
Boolean |
True |
Whether to upload automatically after adding to queue |
Buttonclass |
String |
Empty String |
Add a class name for the Uploadify button |
Buttoncursor |
String |
"Hand" |
Mouse over the browse button to display the mouse style Two values: arrow (arrows), hand (hand shape) |
Buttonimage |
String |
Null |
The path to the background image of the browse button. If you use the default style, you can set the button hover state (this option is a handy option and the best way to assign an image to a button is in a CSS file.) ) |
ButtonText |
String |
"Select FILES" |
The text that appears on the browse button. Note: If you do not modify the uploadify.swf font and uploadify.js file encoding, the use of Chinese will be garbled |
Checkexisting |
String |
|
|
Debug |
Boolean |
False |
Set to True to turn on SWFUpload debug mode. |
Fileobjname |
String |
"Filedata" |
Form key name for receiving file on server side |
Filesizelimit |
Number |
0 |
Maximum size allowed for uploading files. This value can be a number or a string. If it is a string, it accepts a unit (B, KB, MB, or GB). The default unit is KB. You can set this value to 0 without a limit. |
Filetypedesc |
String |
"All Files" |
An optional description of the file. This string appears in the File Type drop-down box in the Browse for File dialog box. |
Filetypeexts |
String |
“*.*” |
The file name extension that is allowed to be uploaded. Multiple file extensions that can be separated by semicolons. namely "*.jpg;*.gif;" Note: If the user types the file name manually, the security level will be bypassed, so you will need to verify the file name type again in the background. |
FormData |
JSON Object |
Empty Object |
An additional JSON object data that will be sent to the server side along with each file. If it is a dynamic value, use the settings () method in Onuploadstart () to change the JSON value |
Height |
Number |
30 |
The height displayed by the browse button |
Method |
String |
"POST" |
How to upload files. Two values: "Get", "POST" |
Multi |
Boolean |
True |
Sets whether to upload as multiple files, and if set to False, only one file can be uploaded at a time |
Overrideevents |
JSON Array |
Empty Array |
An array of event names that you want to bypass for the default script. You can tell the events in the document page that each event can be overridden. |
Preventcaching |
Boolean |
True |
A way to prevent flash caching and collisions, and if set to true, the URL of the flash will add a random number. |
Progressdata |
String |
"Percentage" |
Sets the type of data to display in the File Upload Progress Update queue item. Two values "Percentage" (Display percentage), "Speed" (display rate) |
Queueid |
String |
False |
The element ID that is placed on the upload file queue must be an ID, and unlike the jquery selector, it does not need to add the # number. If False, the queue is automatically added below the browse button. |
Queuesizelimit |
Number |
999 |
The maximum number of files that can be in the queue at one time. This does not limit the number of files that can be uploaded. To limit the number of files that can be uploaded, use Uploadlimit. If the number of files selected to be added to the queue exceeds this limit, the Onselecterror event is triggered. |
removecompleted |
Boolean |
True |
Whether the file is purged from the upload queue (cleared by default) after the file upload is complete. |
Removetimeout |
Number |
3 |
The delay between the completion of the file upload and the removal of this file. Units: Seconds |
Requeueerrors |
Boolean |
False |
If set to True, the upload callback error, re-queued, and multiple attempts to upload the file. |
Successtimeout |
Number |
30 |
After the upload succeeds, it waits for the response time of the server. After this time, if the server is not responding, the default is success (because the upload is complete, just waiting for the server to respond). Units: Seconds |
Swf |
String |
"Uploadify.swf" |
The path of the uploadify.swf in Uploadify, which can be a relative or absolute path. Relative path to the current page path. |
Uploader |
String |
"Uploadify.php" |
The server uploads the script, that is, receives the upload file background processing file path, may be the relative or the absolute path. Relative path to the current page path. |
Uploadlimit |
Number |
999 |
Maximum number of files that you are allowed to upload. When this number is reached or exceeded, the Onuploaderror event is triggered. |
Width |
Number |
120 |
The width of the browse button. |
Note that the Fileobjname property must match the file receive name in your server, otherwise it will not receive the path!
About the use of jquery file upload plugin uploadify 3.1