Detailed jquery uploadify upload file _javascript tips

Source: Internet
Author: User
Tags rar

Online search for a day, everyone said uploadify the only drawback is not to support the Chinese button, cups before, I looked at the next Uploadify API, just found a few parameters have not been mentioned, this is the key to solve this problem. (The habit of looking at the API in the future is firmly developed)
Uploadify There is a parameter is ButtonText this no matter how you do not support Chinese, because the plug-in in JS with a transcoding method to the value of this parameter to the code, decoding the place in that SWF file, see Code, so this road is not.
Another parameter, the Internet is rarely mentioned, is buttonimg (button picture), then you can use a picture to replace the plugin with the black Flash browse button, as long as your own picture is Chinese, this does not solve the Chinese button problem? If you only add this one, you will find your button picture below there is a white area, in fact, that Flash left, white area indicates the mouse available range, this range can be adjusted with Width,height. There is also a parameter wmode its default value is opaque, change it to transparent on the line, that is, the white area of transparency. Then use the method just said, the button click Range set to be as big as your picture is completely OK.

Uploadify usage is not said, online article a lot, and other jquery plug-in usage, is a few file placement path.
The following attached uploadify part of the parameters of the introduction, to see all of the API file to see, generally in the download of the package.

uploader:uploadify.swf file relative path, the SWF file is a text browse button, click and Pop Open File dialog box, default value: uploadify.swf.
Script: The relative path of the background handler. Default value: uploadify.php
Checkscript: Used to determine the relative path of a background handler that uploads selected files to the presence of the server
Filedataname: Sets a name, in the server handler according to the name to fetch the data of the uploaded file. Default is Filedata
Method: Submit to post or get defaults to post
Scriptaccess:flash script file access mode, if the local test is set to always, default value: Samedomain
Folder: The directory where the uploaded files are stored.
Queueid: ID of the file queue, which is the same as the ID of the div that holds the file queue.
Queuesizelimit: When multiple file generation is allowed, set the number of selected files, the default value: 999.
Multi: Multiple files can be uploaded when set to True.
Auto: Set to True when the file is selected directly uploaded, for false need to click the Upload button to upload.
Filedesc: This property value must set the Fileext property before it is valid to set the prompt text in the Select File dialog box, such as setting Filedesc as "Please select rar docpdf file", the effect of opening the file selection box is as follows:
Fileext: Sets the type of file that can be selected, in the format of: ' *.doc;*.pdf;*.rar '.
SizeLimit: Size limit for uploading files.
Simuploadlimit: Allow simultaneous upload of the number of defaults: 1.
ButtonText: The text of the browse button, default: Browse.
BUTTONIMG: The path to the picture of the browse button.
Hidebutton: Set to True hides the picture of the browse button.
Rollover: A value of true and false, when set to true, has a reversal effect when the mouse is moved over the browse button.
Width: Sets the navigation button widths, the default value: 110.
Height: Sets the browse button heights, default value: 30.
Wmode: Set this as transparent to make the flash background file transparent for the browse button, and the Flash file will be placed at the top level of the page. Default value: Opaque.
CANCELIMG: Select the Close button icon on each file after file to the file queue

Uploadify also brought a lot of parameters and useful methods and callback functions, are in the API, although the whole English, but it is easy to understand, here is not said.
Here is the code I used to refer to:

Copy Code code as follows:

<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#uploadify"). Uploadify ({
' Uploader ': ' images/uploadify.swf ',
' Script ': ' <%=request.getcontextpath ()%>/content/importschedulecommitaction.do ',
' cancelimg ': ' Images/cancel.png ',
' Folder ': '/',
' Queueid ': ' Filequeue ',
' Filedataname ': ' Uploadify ',
' Filedesc ': ' Support format: XLS. ',
' Fileext ': ' *.xls ',
' Auto ': false,
' Multi ': true,
' Height ': 20,
' Width ': 50,
' Simuploadlimit ': 3,
' ButtonText ': ' Fdsfdsf ... ',
' buttonimg ': ' Images/browse.jpg ',
' Hidebutton ': true,
' Rollover ': true,
' Wmode ': ' Transparent ',
Oncomplete:function (event, Queueid,fileobj, response, data)
{
$ (' <li></li> '). Appendto ('. Files '). Text (response);
},
Onerror:function (Event,queueid, Fileobj)
{
Alert ("File:" + fileobj.name + "upload failed");
}
Oncancel:function (Event,queueid, Fileobj)
// {
Alert ("Cancel file:" +fileobj.name);
// }
});
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#uploadify"). Uploadify ({
' Uploader ': ' images/uploadify.swf ',
' Script ': ' <%=request.getcontextpath ()%>/content/importschedulecommitaction.do ',
' cancelimg ': ' Images/cancel.png ',
' Folder ': '/',
' Queueid ': ' Filequeue ',
' Filedataname ': ' Uploadify ',
' Filedesc ': ' Support format: XLS. ',
' Fileext ': ' *.xls ',
' Auto ': false,
' Multi ': true,
' Height ': 20,
' Width ': 50,
' Simuploadlimit ': 3,
' ButtonText ': ' Fdsfdsf ... ',
' buttonimg ': ' Images/browse.jpg ',
' Hidebutton ': true,
' Rollover ': true,
' Wmode ': ' Transparent ',
Oncomplete:function (event, Queueid,fileobj, response, data)
{
$ (' <li></li> '). Appendto ('. Files '). Text (response);
}, www.th7.cn
Onerror:function (Event,queueid, Fileobj)
{
Alert ("File:" + fileobj.name + "upload failed");
}
Oncancel:function (Event,queueid, Fileobj)
// {
Alert ("Cancel file:" + fileobj.name);
// }
});

Note that my script property value is a request path, I found that after I set up multiple files (such as 3), not every request to upload 3 files, but still execute 3 requests, upload a file one at a time. This is no way, Uplodify has so many callback functions, if you handle multiple, the callback function parameters do not know what to take, because these parameters are not arrays.
In other words, no matter how many files you set up at the same time, it will be one to request and upload, just on the surface feel like there are multiple threads at the same time processing the upload request, just the appearance. And if you set the simuploadlimit too large will often make mistakes, I set to 5 when there are often one or two files failed to upload.

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: info-contact@alibabacloud.com 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.