Jquery file upload plug-in: example of batch uploading of multiple files with no refreshing AJAX progress

Source: Internet
Author: User
Tags jquery file upload


1, plug-in description

In support of Formdata browser full use of Ajax (that is, XMLHttpRequest) and the input of the files properties together to complete the upload file, otherwise simulate the form submission to upload files. The articles and scripts that support writing are now looking rather immature, and now rearrange, constrain, and better API and ease of use.

Plugin name: Jquery-upload.

2, plug-in use

1, to determine the browser support features
Whether to support the files object of HTML5 input, used to simultaneously choose to upload more than one picture
$.support.inputfiles;
Support for HTML5 Formdata for AJAX submissions
$.support.formdata;

2. Default parameters
$.fn.upload.defaults = {
Submit Address
Action: "",
Passing extra data (key-value pair strings)
Data:null,
Name value of the form file
InputName: "File",
File minimum Capacity (unit B, default 0)
minsize:0,
File maximum capacity (unit B, default 1m=1024kb=1024*1024b)
maxsize:1048576,
File type (file suffix)
FileType: ["png", "JPG", "JPEG", "GIF"],
Error message prompt
ErrorMsg: {
Single File upload error or failure
Singleerror: "{n} file upload error or failure",
Multiple file upload error or failure
Multierror: "Upload error or failure",
Single File not selected
Singlenone: "The {n} upload file has not been selected",
Multiple Files not selected
Multinone: "No upload files have been selected",
Multi-file list is empty
Empty: "The file to be uploaded is empty",
Single, multiple file error, {n} represents the sequence number of the file, starting with the ordinal number 1
Type: "The {n} file type does not meet the requirements",
Size: "{n} file capacity does not meet requirements"
},
Complete a callback, whether successful or unsuccessful
ONCOMPLETE:EMPTYFN,
Successful callback
ONSUCCESS:EMPTYFN,
Failure callback
ONERROR:EMPTYFN,
Progress Callback
Onprogress:emptyfn
};

3, Upload files
$ ("#file"). Upload ({
Action: "upload.php"
});

4, increase the file mime matching relationship
Add a single
$.fn.upload.addtyperelationship ("text/html", "html");
Add multiple
$.fn.upload.addtyperelationship ({
"text/html": "HTML",
"text/xhtml": "XHTML"
});

Related Article

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.