mardi 11 août 2020

cannot upload multiple image using vue.js in Laravel

I want to upload multiple images in laravel, for that i'm using following code but i'm getting error :

message: "Call to a member function getClientOriginalExtension() on string

formData.append('gallery_img[]', this.form.gallery_img); 
uploadGalleryImg(e){
              
                var files = e.target.files;
                if (!files.length)
                    return;

                for (var i = files.length - 1; i >= 0; i--) {
                    this.form.gallery_img.push(files[i]);
                }
            },       

Controller :

 if (count(array($request->gallery_img))) {
        foreach ($request->gallery_img as $image) {
            $fileName = time().'.'.$image->getClientOriginalExtension();
            $image->move(public_path('img/gallery_img/'), $fileName);
        }
 }

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire