Progress Bar Not Working When autoProcessQueue Is False

Progress Bar Not Working When autoProcessQueue Is False

I'm using Dropzone.js to display image on my site.

It is working wonderfully, but there is one problem.

After I realized that Dropzone automatically sends image information without user pressing submit button, I set autoProcessQueue to false.

Now, it doesn't send the information automatically, but progress bar is broken as seen in the picture below.

There seems to be a white line on the image and it doesn't look good.

0

3 Answers

I had a similar problem with the progress bar. I'm using twitter-bootstrap and jQuery in my solution as well. This solution with the progress bar works fine for me (see element with id total-progress).

This is my template:

<!-- Upload preview template begin -->
<div id="preview-template" style="display: none;">
    <div class="dz-preview dz-file-preview" style="display:inline-block;margin:10px;">
        <div class="dz-details">
            <div class="dz-filename label label-primary">
                <span data-dz-name></span>
            </div>
            <br style="line-height:2px;" />
            <div class="dz-error-message label label-danger" style="display:none;clear:both;">
                <span data-dz-errormessage></span>
            </div>
            <br style="line-height:2px;" />
            <!--<div class="dz-size" data-dz-size></div>-->
            <img data-dz-thumbnail style="border-radius:5px;clear:both;" />
        </div>
        <!--<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>-->
        <!-- <div class="dz-success-mark"><span>?</span></div> -->
        <!-- <div class="dz-error-mark"><span>?</span></div> -->
        <div data-dz-remove class="btn btn-default removePicFromAlbum" title="Entfernen"><span class="glyphicon glyphicon-remove center-block" aria-hidden="true"></span></div>
        <div id="total-progress" class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" style="width:100px;">
            <div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress></div>
        </div>
        <!--<img src="removebutton.png" alt="Click me to remove the file." data-dz-remove />-->
    </div>
</div>
<!-- Upload preview template end -->

And here is my Javascript code:

Dropzone.autoDiscover = false;
var {{$name or 'upload'}} = new Dropzone("div#{{$name or 'upload'}}", {
    url: "{{ action("$controllerClass@store") }}"
    , method: "post"
    , paramName: "file" // The name that will be used to transfer the file
    , maxFilesize: {{$maxFilesize or str_replace('M','',ini_get('upload_max_filesize')) }} // MB
    , uploadMultiple: false
    , dictDefaultMessage: "{{$text or 'Ziehen Sie Dateien in diesen Bereich, um diese hochzuladen'}}"
    , previewTemplate: document.getElementById('preview-template').innerHTML
    //, acceptedFiles:'image/*'
    , previewsContainer: '#logoPreview'
    , thumbnailWidth: {{$thumbnailWidth or 100}}
    , thumbnailHeight: {{$thumbnailHeight or 100}}
    , sending: function (file, xhr, formData) {
        formData.append('_token', '{!!csrf_token() !!}');
    }
    , success: function(file, responseText) {
        if(responseText != undefined) {
            if (responseText.success != undefined && responseText.success == "false") {
                $(file.previewElement).find('.dz-error-message').text("Fehler: " + responseText.errorMessage);
                $(file.previewElement).find('.dz-error-message').css('display','inline-block');
            }
            else {
                $(file.previewElement).find('.dz-error-message').css('display','none');
            }
        }
        $(file.previewElement).find('#total-progress').css('display','none');
    }
    , error: function(file, message, xhr) {
        var header = "Error " + xhr.status + ": " + xhr.statusText;
        $(file.previewElement).find('.dz-error-message').text(header);
        $(file.previewElement).find('.dz-error-message').css('display','inline-block');
        $(file.previewElement).find('#total-progress').css('display','none');
    }
    , uploadProgress: function(progress) {
        document.querySelector("#total-progress .progress-bar").style.width = progress + "%";
    }
    , completed: function(progress) {
        $(file.previewElement).find('#total-progress').css('display','none');
    }
    , removedfile: function(file) {
        removeFile(file.name);
        $(file.previewElement).remove();
    }

    });

You binded progress bar to wrong event. Replace uploadProgress by uploadprogress.

Doc is here:

1

This post may be old but I got easy answer. So I am posting here for anyone who needs help on this.

Remove autoProcessQueue: false and set url: "#". When you set the url: "#", then dropzone can't process automatically but autoProcessQueue: true (by default) will help to trigger animation

This way, it worked for me

Dropzone.options.dropzoneForm = {
                addRemoveLinks: true,
                url: "#",
                init: function () {

                }
            };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.