I have created a very simple file drag and drop mechanism using javascript.
Using this, I can drag a file (or multiple) from Windows Explorer and drop it onto an <input type="file"/>
element. The aim is to provide the user with a nice alternative to clicking the "Browse" button on the <input type="file"/>
element and selecting a file manually).
The "file drop" is handled as follows:
HTML
<input type="file" ondrop="ondropfile(event);"/>
Javascript (I simply allow the input type="file" default action to occur - without propagation)
ondropfile = function(e) {
e.stopPropagation();
return false;
};
The above works for Chrome, Firefox, Safari and Opera, BUT NOT Internet Explorer! (as at version 11)
In IE, when I drop a file onto my <input type="file"/>
element the entire page is overwritten and the contents of the file I have dropped are displayed. To illustrate the behaviour one can test http://jsfiddle.net/andreymir/H3RR7/light/ in Internet Explorer as compared to other browsers.
Does anyone know how to drop a file onto an <input type="file"/>
element in Internet Explorer using HTML and Javascript?