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"
});