I want to use ajax to upload image. In this module:
browse and selecting image, it will be uploaded and displayed over file field.
Actualy you can upload images with the ajax function in Jquery in atleast the lates version of chrome.
HTML:
JS:
$("form").submit(function(){
var formData = new FormData($(this)[0]);
$.ajax({
url: window.location.pathname,
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (data) {
alert(data);
}
});
return false;
});
This script will send a post request with the created file data to the current page through Ajax. You can change the destination obviously through changing the url parameter.