Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

javascript - upload videos with laravel and dropzone

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...