I am trying to pass an image and a title field value to PHP, I usually process file uploads straight with PHP using the $_FILES array, I am not sure how to create/pass this
First You need to Select image file through following line of html code
input type="file" id="image_to_upload"
After that you need to write the following jQuery code to catch this event.
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(){} }); } });
In the destination ajax file you can access image by the following variable
print_r($_FILES);
More Info: http://www.rscoder.com/2020/06/how-to-upload-image-file-using-ajax.html