JS:
var file = e.originalEvent.dataTransfer.files[0];
var formData = new FormData();
formData.append('file', file)
$.ajaxSetup ({
processData: false
});
$.post('/addaltproduct',
{
file: formData
},
function (data) {
console.log(data);
}).fail(function (xhr, textStatus, errorThrown) {
console.log(xhr.responseText);
});
Controller:
if ($request->file('file')) {
return 'OK';
}
return 'No file';
In return I always get 'No file', though if I run console.log(formData.get('file')) in JS it shows me the data.