1. In this tutorial we are going to tell you that how to send an image through ajax to process.
2. In the following code you can process image as soon as it is selected.
3. First You need to Select image file through following line of html code
<input type="file" id="image_to_upload"/>
4. After that you need to write the following jQuery code to catch this event.
<script type="text/javascript"> jQuery.noConflict(); formdata = new FormData(); jQuery("#image_to_upload").on("change", function() { var file = this.files[0]; if (formdata) { formdata.append("image", file); jQuery.ajax({ url: "destination_ajax_file.php", type: "POST", data: formdata, processData: false, contentType: false, success:function(){} }); } }); </script>
5. In the destination ajax file you can access image by the following variable
$_FILES["image"]["name"]
6.That is it Save And Enjoy!!