LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Problems with Drag&Drop #132

Closed krivochenko closed 8 years ago

krivochenko commented 8 years ago

Hi I try to show images preview before sending:

....
dropzone: $widget.find('.dropzone'),
....
onChange: function (filename, extension, size) {
    var reader = new FileReader();
    reader.onload = function (e) {
        $widget.find('.new_photo_area').append('<img src="' + e.target.result + '">');
    };
    reader.readAsDataURL(this._input.files[0]);
},
....

If I choise a file by clicking the dopzone and finding via explorer, it works fine. But, when I try drag and drop file to the .dropzone, property this._input.files is empty and I get error:

Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

Thanks for help.

LPology commented 8 years ago

Fixed with version 2.3 release. The onChange() callback now receives the selected file as its 5th argument. Feel free to reopen or create another issue if other problems arise. Thanks for your input.