mercredi 5 décembre 2018

I am trying to upload multiple images in laravel and facing issues as the same image is uploaded each time?

The problem is that my loop only running and uploading the same first pic each time rather than uploading each other in a row one after one!

Here is my code of the form

{!! Form::file('photos[]', ['roles' => 'form', 'class' => 'form-control-file','multiple' => true]) !!}

Here is my code of the controller

            $files=$request->file('photos');
            foreach ($files as $file) {   
            $insert = new Images;
            $insert->youth_fashion_images_category = $request->selectproduct; 
            $destinationPath = 'uploads/products';
            $imageName = 'uploads/products/'.time().'.'.$file->getClientOriginalExtension(); 
                $insert->Save();
                $uid = $insert->id;
             $file->move($destinationPath,$imageName);
             $image = array(
                'youth_fashion_images_img' => $imageName
            );
             Images::where('youth_fashion_images_id',$uid)->update($image);    
           }


             return redirect('adminpanel/viewimages');



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zIfLVa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire