Answer the question
In order to leave comments, you need to log in
File not sending via ajax - Yii?
Not sending file via ajax - Yii
Returning to server
$_POST - empty array
$_FILES - empty
var file = document.getElementById(window.image_input_original).files[0];
var fd = new FormData();
fd.append(window.image_input_original, file, window.image_input_original+'.jpg');
$.ajax({
type: "POST",
processData: false,
contentType: 'multipart/form-data',
url: _jcropOptions['url'],
data: {form:fd,field_model:window.image_input},
success: function(data){
console.log( "Прибыли данные: " + data);
},
error: function(data){
console.log( "Ошибка: " + data );
},
});
$post = Yii::$app->request->post();
$uploadParam = $post['field_model'];
$model = new DynamicModel([$uploadParam]);
parse_str($post['form'],$params);
var_dump($_POST);
var_dump($_FILES);
die();
$model->load($params);
$model->{$uploadParam} = UploadedFile::getInstance($model, $uploadParam);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question