Really simple jQuery Ajax File Upload plugin
Well, it's not really Ajax uploading considering file upload with ajax is not possible, but the end result is similar.
This jQuery ajax upload plugin creates a hidden iframe and sets the form's target attribute to post to that iframe. When the form is submitted, it is posted (including the file uploads) to the hidden iframe. Finally, the plugin collects the server's response from the iframe.
You can of course easily upload multiple files simply by including more file fields.
- Version 1.1
- Load event would get attached each time the form was submitted, resulting in the event being attached multiple times.
- New Feature
- Treat the server response as a JSON object and parse using
- New Feature
- Returning false in the
post : function ()callback function will abort the submission of the form.
jQuery Ajax Upload API;
iframeID : 'iframe-post-form'
- The iframe's ID & name.
json : false
- Treat the server response as a JSON object, apply jquery.and return the parse JSON object (new in version 1.1).
post : function ()
- When the form has been submitted.
- Returning false in this call back function will abort the submission of the form (new in version 1.1).
complete : function (response)
- After everything has been submitted and completed.
Thanks to Federico Rampazzo for spotting a flaw in the PHP code of this page.