JQuery.AjaxFileUpload.js is a jquery plug-in for uploading files via Ajax.
Grammar:
$.ajaxfileupload ([options])
Options parameter Description:
1, URL upload processing program address.
2,fileelementid the ID of the file domain that needs to be uploaded, that is, <input type= "file" >.
3,secureuri whether security commits are enabled and false by default.
The type of data returned by the 4,datatype server. can be for xml,script,json,html. If you do not fill in, jquery will automatically judge.
5,success the processing function that is executed automatically after the commit is successful, and the parameter data is the server returns.
6,error the processing function that the commit failed to perform automatically.
7,data custom parameters. This thing is more useful, when the data is related to the uploaded pictures, this thing will be used.
8, type when the custom parameter is to be submitted, this parameter is set to post
function characteristic:
It does not rely on specific HTML, just give it a "< inputtype=" File >
It does not require your server to respond when specifying any particular way
Can operate on a large batch of files
Sample code:
--use as little as-
$ (' #one-specific-file '). Ajaxfileupload ({
' action ': '/upload.php '
});
--or as much as-
$ (' input[type= ' file '] '). Ajaxfileupload ({
' action ': '/upload.php ', '
params ': {
' Extra ': ' Info '
},
' OnComplete ': function (response) {
Console.log (' Custom handler for file: ');
Alert (json.stringify (response));
},
' OnStart ': function () {
if (wewantedto) return false;//cancels Upload
},
' OnCancel ': function () {
console.log (' No file selected ');
}
);
About Ajaxfileupload implementation of a single file of Ajax file upload library to introduce to everyone here, I hope to help you!