jeudi 12 septembre 2019

upload multiple files at the same time without a duplicate in Laraval

I use this code to upload multiple files together in Laravel But all name files are duplicated

if (is_array($files) || is_object($files)) {
            foreach ($files as $file) {
                $name = time() . '.' . $file->getClientOriginalExtension();
                $file->move(public_path('uploadmusic'), $name);
                PostPhoto::create([
                    'post_id' => $post->id,
                    'filename' => $name
                ]);

            }
        }

1568314601.png
1568314601.png
1568314601.png

please guide me




Aucun commentaire:

Enregistrer un commentaire