我正在尝试上传图片但收到错误Uncaught (in promise) Error: Request failed with status code 404
这是我的代码
<input type="file" id="file" class="form-control-file" v-on:change="onFileChange">
methods:{
goToLogin(){
this.upload();
},
onFileChange(e){
console.log('onFileChange');
let files = e.target.files || e.dataTransfer.files;
if(!files.length){
return;
}
this.createImage(files[0]);
},
createImage(file){
console.log('createImage');
let reader = new FileReader();
let vm = this;
reader.onload = (e) =>{
vm.image = e.target.result;
};
reader.readAsDataURL(file);
},
upload(){
console.log('upload image= '+this.image);
axios.post('/storage/images',{image: this.image}).then(response => {
console.log(response.data);
});
}
}
public function saveImage(Request $request){
$image = $request->file('image');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('images/' . $filename);
$user->image = $filename;
$user->save();
}
在上传方法中,我会在图片中获取数据,但问题是在&#39; / storage / images&#39;内。任何人都可以帮我修理它。