0
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';
Im Gegenzug erhalte ich immer 'Keine Datei', obwohl, wenn ich console.log(formData.get('file'))
in JS führen Sie es mir die Daten zeigt.
I don‘ Ich weiß genau, was passiert. Das Formular zum Hochladen der Datei sollte jedoch die folgenden Attribute haben: 'method =" post "enctype =" multipart/form-data "' – SaidbakR