Hello, I need to add an image via ajax, but I cannot accept the file (returns null), please tell me what I'm doing wrong.
ajax:
var form_data = new FormData('img', img_file.prop('files')[0]); $.ajax({ type: "POST", //Метод отправки url: "/upload_image", //путь до php фаила отправителя processData: false, dataType: 'json', data: form_data, success: function(success) { console.log(success) form_data = undefined; console.log('zbs' + form_data) } }); Controller:
public function upload_product_image(Request $request){ $key = $request->key; $picture = Input::file("img"); return response()->json(['picture' => $picture]); } Another question: how to simultaneously transfer other variables with the file?
form_data.append(name, value);- Orange_shadow