Ich versuche, Datei mit Ajax in yii2 hochladen. aber es Browser-Konsole zeigt es 400 Bad Request in meinem site_url was mein Fehler ist .. Bitte jemand helfen.Ajax-Fehler 400 schlechte Anfrage
var site_url = '<?php echo Url::to (['formdata/movefile','id'=>'']); ?>' + unic ;
var file_data = $('#formdata-'+ form + '-' + component + '-c_data').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url: site_url, // point to server-side PHP script
dataType: 'TEXT', // what to expect back from the PHP script, if anything
cache: false,
contentType: false,
processData: false,
data: { form_data:form_data,_csrf : '<?=Yii::$app->request->getCsrfToken()?>'},
type: 'POST',
success: function(php_script_response){
alert(php_script_response);
}
});
yaa .. es crct ... Mein Fehler ist in csrf Freigabe Validierung – Prabhakaran