In-depth analysis of ajaxfileupload implementation of a single file Ajax file upload library _ajax related

Source: Internet
Author: User

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!

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.