I want to upload some files, but when i post with axios, my formdata is an empty request in laravel
vuejs: uploader.vue
filesChange(e) {
const fileList = e.target.files;
const formData = new FormData();
if (!fileList.length) return;
for (let i = 0; i < fileList.length; i += 1) {
console.log(fileList[i]);
formData.append('files', fileList[i], fileList[i].name);
}
this.save(formData);
},
output from console, all files are looped and appended to formData
save(formData) {
photosApi.storePhotos(formData, this.galleryId).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
},
vuejs: photosApi.js
storePhotos(formData, id) {
return axios.post(`api/photo/${id}`, formData);
},
when i inspect my api-call i see this
laravel: api.php
Route::post('/photo/{id}', 'PhotoController@store');
laravel: PhotoController.php
public function store(Request $request, $id)
{
return $request->all();
}
the return of my response is only empty...
what im'doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire