Vue Version : 2.6.10
Laravel Version : 6.0
I am using this vue upload package and everything is ok on client side (at least I think so). But on the server side, where I am using the laravel, have some problem.
Here is my vue send method:
setImage: function (file) {
let formData = new FormData();
formData.append('file', file);
axios.post(upload_route, formData , {
headers: { 'Content-Type': 'multipart/form-data' }
})
.then(response => {
// upload successful
})
.catch(error => console.log(error));
},
And this is my server side method:
public function upload(Request $request){
$path = $request->file('file')->store('avatars');
return response('upload success' , 200);
}
When I upload the file to the server, it gives me this error:
"message": "Call to a member function store() on null",
The file object I am sending in the setImage function is something like this (if I log it with console.log):
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE...