At moment I want to implement picture upload without using any plug-ins.
My upload form looks like this
AJAX
or more appropriately XMLHttpRequest
does not support file uploads yet. There are workarounds such as uploading through an , but its rather cumbersome. Your time will be better spent in building your applications rather than reinventing these solutions.
But if you're curios as to how it works internally, then feel free to checkout the source code of some of the plugins that offer this functionality. A very simple explanation can be found at this link - http://www.openjs.com/articles/ajax/ajax_file_upload/
Basically, you change the form target
to submit inside an , thus avoiding the page refresh, and simulating AJAX, which it isn't really, but who cares - the end user can't tell.
A minimal example for an iframe based upload may look like this:
$("#upComplete").click(function() {
// create a dynamic iframe, or use existing one
var iframe = $("
Note that this does not do any response handling, but just sends the picture to the server. To handle the response, a callback must be written for the iframe's load
event.