Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 712b521

Browse files
committed
Prevent default action only when dragging/dropping files - Fixes #1897.
Thanks to Ville Lautanala (lautis) for his contribution.
1 parent 1fd38f2 commit 712b521

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

js/jquery.fileupload.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.19.4
2+
* jQuery File Upload Plugin 5.19.5
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -952,10 +952,12 @@
952952
},
953953

954954
_onDrop: function (e) {
955-
e.preventDefault();
956955
var that = this,
957956
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
958957
data = {};
958+
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
959+
e.preventDefault();
960+
}
959961
this._getDroppedFiles(dataTransfer).always(function (files) {
960962
data.files = files;
961963
if (that._trigger('drop', e, data) !== false) {
@@ -969,10 +971,10 @@
969971
if (this._trigger('dragover', e) === false) {
970972
return false;
971973
}
972-
if (dataTransfer) {
974+
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
973975
dataTransfer.dropEffect = 'copy';
976+
e.preventDefault();
974977
}
975-
e.preventDefault();
976978
},
977979

978980
_initEventHandlers: function () {

0 commit comments

Comments
 (0)