I have an image uploader from Vuetify that allows a user to add images to upload. It stores them in a v-model files
. Files is an array of file objects shaped like this:
this.files = [
0: {
lastModified: 1588138776398
lastModifiedDate: Wed Apr 29 2020 01:39:36 GMT-0400
(Eastern Daylight Time) {}
name: "video-pause.png"
size: 932
type: "image/png"
webkitRelativePath: ""
}
]
I then have a button to submit the files to the backend endpoint with this function:
uploadAssets: function() {
axios.post('/upload-images', {
images: this.files,
})
.then(response => {
debugger
})
}
My Laravel backend controller that should be receiving the images looks like this:
public function uploadImages(Request $request)
{
print $request->file('images');
if ($request->hasFile("images")) {
log_info($request->file('images'));
$files = $request->file('images');
$stack = [];
foreach ($files as $file) {
$fileName = Storage::put(shop_id().'/assets/', file_get_contents($file->getRealPath()), ['visibility' => 'public']);
array_push($stack, $fileName);
}
return response()->json($stack);
}
}
My issue is that the print log in the backend method is showing the images as [{}]
. I can't tell why the data is not being sent over.