vendredi 26 avril 2019

Upload gif images in Laravel 5.7

I am trying to upload an gif image.It displays the image with first frame and animation get disappears. Here is my code to upload an image on change it calls selectfile

                 <div class="form-group">
                    <img :src="getImagePhoto()" alt="Image Photo" style="width:200px;"/>
                    <input id="image" type="file" name="image"
                        placeholder="Image" @change="selectFile"
                        class="form-control">
                </div>

getImagePhoto it is shows the image in the frontend

        getImagePhoto(){
            if(this.form.image != null){
                let photo = (this.form.image.length > 200) ? this.form.image : "img/"+ this.form.image ;
                return photo;
            }       
           return   ;
        },

Uploads the image

        selectFile(e) {
            let file = e.target.files[0];
            let reader = new FileReader();

            reader.onloadend = (file) => {
                this.form.image = reader.result;
            }
            reader.readAsDataURL(file);

        },

PHP code to upload the image

    if($request->image ){
        $name = time().'.' . explode('/', explode(':', substr($request->image, 0, strpos($request->image, ';')))[1])[1];


        \Image::make($request->image)->save(public_path('img/').$name);
        $request->merge(['image' => $name]);


    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire