dimanche 1 décembre 2019

How to upload multiple images with the same order of selection in Laravel

My question is very similar to this question How to upload multiple images with the same order of selection in php .In my case the selected images are inserted randomly and uploaded to the database randomly. I would like if I selected a.jpg, b.jpg and c.jpg, to be inserted in the same order so the first image should be a.jpg and so on. How can I solve this problem?

Controller

$product = product::create(array_merge($formInput, [
        'seller_id'=> Auth::user()->id,
        'user_id' => Auth::user()->id
    ]));
    foreach ($request->photos as $photo) {
       $filename = $photo->store('public/photos');
        ProductsPhoto::create([
            'product_id' => $product->id,
            'filename' => $filename
        ]);
    }

Blade

<input "multiple="multiple" id="photos" name="photos[]" type="file">


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire