Here is the code for uploading an image or file without submitting a form with Ajax. For this we will create object of FormData class and will append the properties of the file field in a attribute of FormData object, finally we will set the FormData object with the data key of ajax method of JQuery.
We can get the parameters of file field by accessing the “file” key of the parameters hash.
Sorry to say, but the FormData class is not supported in IE.
If you are looking for a solution that works on all browsers have a look at Upload image without submitting form, works on all browsers.