I am trying to save image and other forms data with ajax, But Some problems facing while uploading image. Image is selected and Sent from js but in php $_FILES not getting this image its return blank
IN js
var datastr = 'productionstrategyno='+productionstrategyno+
'&manufacturingleadtime='+manufacturingleadtime;
if (($("#item-master-image"))[0].files.length > 0) {
file = ($("#item-master-image"))[0].files[0];
datastr += '&images='+file;
}
$.ajax({
url: base_url+'ajax_response/item_master',
type: 'post',
data: datastr,
dataType: 'json',
enctype: 'multipart/form-data',
processData: false, // do not process the data as url encoded params
success: function(json) {
if(json.status="200"){
msgalert(json.msg,"success");
window.location.href=base_url+"master/listItem";
}else{
msgalert(json.msg,"danger");
}
}
});
It's send to php giving
isstandardmaterial:1
ismaintainbincard:1
images:[object File]
In PHP
<?php print_r($_FILES['images']); ?>
It return blank array value