I was reading the HTML5 specification on drag and drop operations yesterday. I thought that if you could drag files into your browser, why not make it so you can drag links to files out of the browser? Currently, if you drag a link to a file out of the browser into a folder, all you get is a shortcut to the file in the folder. It would be handier to (as the website operator) set some kind of flag so that the user can drag that link to a folder and have it save the file. You can save a displayed image to your hard drive by dragging it into a folder, but a link to an image dragged out of the browser would just give you a shortcut to the image's URL. What if you want to put a link to a ZIP file and have the user drag and drop it to the desired location rather than telling them to right-click the file and click whatever browser-specific menu item to save the link? ("Save Link As..." in Firefox and Chrome or "Save target as..." in IE) There's security implications of having JavaScript and my idea might not work, but I have an idea of how the code for it might look. For example (this is only code demonstrating what I'm talking about...it doesn't work):
<a href="http://www.example.org/downloads/file.ext" rel="dragentirefile" type="audio/ogg" id="some-link">Right-click or drag to save</a>
Of course, the name of the link type (the REL attribute) could be anything. It would be nice if there was a way to use the
setDragImage method from the HTML5 DataTransfer interface to set an image to be displayed as the file is being dragged. In my example of an Ogg Vorbis file, the image could be the album cover for whatever song. A text file might show some of the file contents. If a type is specified (in this case, "audio/ogg" for an Ogg Vorbis audio file), but no drag image is specified, the system could pick an appropriate icon for the file drag process. Maybe if the type attribute is set, the browser could figure what was meant by the user dragging the link out of the browser. I was trying to think of ways this could be abused, but it's no less safe than just allowing the user to right-click a link and save the file.