Hello,
I would like to use image uploading with Ajax post. My codes are as follows;
<input type="file" id="file" data-size="sm" data-badge="false" data-iconName="glyphicon-inbox" data-buttonName="btn-primary" name="receipt">
$.ajax({
url: '',
type: "post",
data: {'_token': '{{ csrf_token() }}','receipt':$('#file').val()}
});
$receipt = $request->file('receipt');
$fileName = $receipt->getClientOriginalName();
$fileExtension = $receipt->getClientOriginalExtension();
$name = str_slug($fileName) . str_slug(str_random(5)) . '.' . $fileExtension;
$move = $receipt->move('Backend/avatar/',$name);
$ex->receipt = $name;
$ex->save();
But, I am getting this error;
Call to a member function getClientOriginalName() on null
I have a lot of inputs. The form is like Personal Info. I have to use my codes like that. How can I solve this ?