I am trying to upload image using vuejs and laravel through api. In vue.js I send the image info to laravel through api. but laravel do not get the info in correct format. that's why it shows an error. May be my procedure is not right.
Here is my codes
Vue.js codes
`
<input type="file" accept="image/*" @change="doctorImageSelected(event)">
<button style="float: left;" class="ajmal-custom-btn" @click="goToUploadImage()">Upload</button>
`
`
doctorImageSelected (event) {
let image = event.target.files[0]
this.image = image
// console.log(this.image)
let reader = new FileReader();
reader.readAsDataURL(image);
reader.onload = event => {
this.image = event.target.result
}
},
goToUploadImage(){
var self = this
this.$http.post(apiDomain + 'api/savePatientProfilePicture',{pic: self.image,id: self.id})
.then(response => {
if(response.status === 200){
console.log(response)
}
}).catch((e) => {
console.log(e)
})
}
`
Laravel code
`
public function savePatientProfilePicture(Request $request){
$pictureInfo = $request->pic;
$picName = $request->id . $pictureInfo->getClientOriginalName();
return $picName;
$folder = "patinetImage/";
$pictureInfo->move($folder,$picName);
$picUrl = $folder.$picName;
$user = new User();
$patientPic = User::find($request->id);
$patientPic->image = $picUrl;
$patientPic->save();
}
`
Error
Call to a member function
getClientOriginalName()
on string