[Vuejs]-Why Laravel stores only the last file when I upload several files at the time?

0👍

As per the doc (https://laravel.com/docs/7.x/filesystem#file-uploads)

the move method may be used to rename or move an existing file to a
new location:

So by doing: $file->move(storage_path('uploads'), $name); it won’t achieve what you are looking for.

You may instead use;


    foreach($request->file('file') as $file)
    {
        $name = time().'.'.$file->getClientOriginalExtension();
        $file->store('uploads');
        $data[] = $name;
    }

Leave a comment