cybermatatu / dnd-file-upload

Automatically exported from code.google.com/p/dnd-file-upload
0 stars 0 forks source link

Progress bar for uploading files freeze after a second drop #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Comment the following line. Reason to do this to keep current in progress 
uploads after a new drop.

JQ.fn.dropzone.newFilesDropped = function () {
    //JQ(".dropzone-info").remove();
};

What is the expected output? What do you see instead?
Keep current uploading files in the info section and add new dropped files to 
the list

It adds the new files but the progress for the files dropped before freezes. 
Files will be uploaded but progress bar remains there frozen.

Original issue reported on code.google.com by ergecsen...@gmail.com on 14 Sep 2011 at 10:08

GoogleCodeExporter commented 9 years ago
Ok I found the problem. In jquery.dnd-file-upload.js this line

for ( var i = 0; i < files.length; i++) {

resets index on every file drop and this affects updating and hiding info divs.

I'll post the fix soon.

Original comment by ergecsen...@gmail.com on 14 Sep 2011 at 11:21

GoogleCodeExporter commented 9 years ago
Here is the fix I did for my own project. This issue may be solved with a 
better way.

I created counter on page load for my dropzone

$("#dropzone").data("totalfilecount", 0);

then

In this function do

JQ.fn.dropzone.uploadStarted = function (fileIndex, file){
    fc = parseInt($("#dropzone").data("totalfilecount"), 10) + 1;
    $("#dropzone").data("totalfilecount", fc);

    //rest of the code
};

JQ.fn.dropzone.newFilesDropped = function () {
    //JQ(".dropzone-info").remove();
    return parseInt($("#dropzone").data("totalfilecount"), 10);
};

In jquery.dnd-file-upload.js edit uploadFiles function like this

    function uploadFiles(files) {
        var filecount = $.fn.dropzone.newFilesDropped();
        for ( var i = 0; i < files.length; i++) {
            ...
            ...
            ...
            upload.fileIndex = filecount + i;
            ...
            ...
            ...
            $.fn.dropzone.uploadStarted(filecount + i, file);
        }
    }

Original comment by ergecsen...@gmail.com on 14 Sep 2011 at 11:31

GoogleCodeExporter commented 9 years ago
https://github.com/ergec/dnd-file-upload

Original comment by ergecsen...@gmail.com on 14 Sep 2011 at 11:54