Home > Article > Web Front-end > An in-depth analysis of AjaxFileUpload to implement the Ajax file upload library for a single file
jQuery.AjaxFileUpload.js is a jQuery plug-in for uploading files through ajax. This article introduces AjaxFileUpload to implement the Ajax file upload library for a single file. Friends who are interested in this should learn together
jQuery.AjaxFileUpload.js is a jQuery plug-in for passing ajax upload files.
Syntax:
$.ajaxFileUpload([options])
options Parameter description:
1. url Upload handler address.
2, fileElementId The ID of the file field that needs to be uploaded, that is, the ID of 3525558f8f338d4ea90ebf22e5cde2bc.
3, secureuri Whether to enable Secure submission, the default is false.
4, dataType Data type returned by the server. Can be xml, script, json, html. If you don't fill it in, jQuery will automatically determine it.
5, success is a processing function that is automatically executed after successful submission. The parameter data is the data returned by the server.
6,error Handling function that is automatically executed if submission fails.
7, data Custom parameters. This thing is more useful. When there is data related to the uploaded image, this thing will be used.
8, type When you want to submit custom parameters, this parameter must be set to post
Function features:
It doesn't depend on specific HTML, just give it a " d43048cbf8ebcf365597e7e4eb37ac81
It doesn't require your server to respond in any specific way
That's OK Operate large batches 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 to implement the Ajax file upload library for a single file. The introduction is here, I hope it will be helpful to everyone!
Related recommendations:
Ajax request and Filter cooperation cases
##ajax fast How to solve the problem that the parameter is too long and cannot be submitted successfully
Ajax submission of the Form form page will still refresh jSolution
The above is the detailed content of An in-depth analysis of AjaxFileUpload to implement the Ajax file upload library for a single file. For more information, please follow other related articles on the PHP Chinese website!