Answers for "Laravel Dropzone Attachment Preview"

PHP
2

Laravel Dropzone Attachment Preview

init: function () {
      @if(isset($user) && $user->picture)
        var file = {!! json_encode($user->picture) !!}
            this.options.addedfile.call(this, file)
        this.options.thumbnail.call(this, file, file.preview)
        file.previewElement.classList.add('dz-complete')
        $('form').append('<input type="hidden" name="picture" value="' + file.file_name + '">')
        // NOTE: Adding the Download link
        var preview = document.createElement('a');
        preview.setAttribute('href',file.preview);
        preview.setAttribute('target','_blank');
        preview.setAttribute('class','fa fa-file');
        preview.innerHTML = " Preview";
        file.previewTemplate.appendChild(preview);
        // NOTE: Adding the Download link (END)
        this.options.maxFiles = this.options.maxFiles - 1
      @endif
    },
Posted by: Guest on September-05-2021

Browse Popular Code Answers by Language