FileReader error: The object is already busy reading Blobs

后端 未结 2 1038
你的背包
你的背包 2021-02-18 16:33

I\'m making a drag-and-drop file upload system for photo gallery uploads. This is my source code handling dropped files. This one works multiple files if I drop them one by one

2条回答
  •  孤独总比滥情好
    2021-02-18 17:14

    I think the error is already given to you.

    Failed to execute 'readAsDataURL' on 'FileReader': The object is already busy reading Blobs

    So the file reader is already busy but only when you drop multiple files? Then it is probably busy with the first file (and the second crashes).

    When you put var reader = new FileReader(); in your jQuery each loop it will work like below:

    $.each(files, function(i, j)
    {
        var reader = new FileReader();
        $("td.photos span.status").html("Processing file: "+j.name);
    
        formdata.append('file', j);
        .... 
    
    }
    

提交回复
热议问题