0

i´m traying to upload one video with dropzone and laravel, but when y select other type dropzone upload file ok and don´t return error and i need that only accept video type and if i select other type return a message. my actual code is:

 var var15671147011688676454ble = '';
                @if(isset($restaurant) && $restaurant->hasMedia('video'))
                    var15671147011688676454ble = {
                        name: "{!! $restaurant->getFirstMedia('video')->name !!}",
                        size: "{!! $restaurant->getFirstMedia('video')->size !!}",
                        type: "{!! $restaurant->getFirstMedia('video')->mime_type !!}",
                        collection_name: "{!! $restaurant->getFirstMedia('video')->collection_name !!}"
                    };
                @endif
                var dz_var15671147011688676454ble = $(".dropzone.video").dropzone({
                        url: "{!!url('panel/uploads/store')!!}",
                        acceptedFiles: "video/mp4, video/x-msvideo" ,
                        addRemoveLinks: true,
                        maxFiles: 1,
                        
                        init: function () {
                            @if(isset($restaurant) && $restaurant->hasMedia('video'))
                                dzInit(this, var15671147011688676454ble, '{!! url($restaurant->getFirstMediaUrl('video','thumb')) !!}')
                            @endif

                            this.on("error", function(file, message) {

                                $('.content').prepend(`<ul class="alert alert-danger" style="list-style: none;">
                                                            <li>
                                                                ${message}
                                                            </li>
                                                        </ul>`);
                                this.removeFile(file); 
                            });

                            this.on("success", function(file, message) {
                                $('.alert-danger').remove();
                                $('.content').prepend(`<ul class="alert alert-success" style="list-style: none;">
                                                            <li>
                                                                {{trans('validation.dropzone_success')}}
                                                            </li>
                                                        </ul>`);
                            });


                        },
                        accept: function (file, done) {
                            dzAccept(file, done, this.element, "{!! config('medialibrary.icons_folder') !!}");
                        },
                        sending: function (file, xhr, formData) {
                            dzSending(this, file, formData, '{!! csrf_token() !!}');
                        },
                        maxfilesexceeded: function (file) {
                            dz_var15671147011688676454ble[0].mockFile = '';
                            dzMaxfile(this, file);
                        },
                        complete: function (file) {
                            dzComplete(this, file, var15671147011688676454ble, dz_var15671147011688676454ble[0].mockFile);
                            dz_var15671147011688676454ble[0].mockFile = file;
                        },
                        removedfile: function (file) {
                            dzRemoveFile(
                                file, var15671147011688676454ble, '{!! url("panel/restaurants/remove-media") !!}',
                                'video', '{!! isset($restaurant) ? $restaurant->id : 0 !!}', '{!! url("panel/uplaods/clear") !!}', '{!! csrf_token() !!}'
                            );
                        }

In my function init i have a alert message for success response and error response, but if i select a image, don´t return message

daviserraalonso
  • 75
  • 1
  • 13

1 Answers1

0

May be this is what you are looking for.

Dropzone.options.recommendationDiv = {
    acceptedFiles: 'image/*'
};

May be this is what you are looking for. already answered here

See Dropzone's configuration documentation.