views:

288

answers:

3

I am sure it's possible to be able to drag files onto a Flash movie inside a browser, but is it possible to achieve the same functionality with Javascript?

I have seen a site (can't remember) that did this, but I never checked if it was a pure Javascript solution compared to a Flash solution.

I am leaning towards the not side, I believe that breaks the limitations of Javascript, although if there is any solution I would love to hear it. My only worry is it won't be supported that well across different browsers.

+1  A: 

I don't think it's possible to drag a file into a page as such.

Though some browsers may allow you to drag a file into a file upload input box. If this is the cease, perhaps you could stretch such an input via CSS and make it transparent/overlay on background to provide a "pretty" drop target.

levik
+1  A: 

You can do this with ActiveX, though it would only work in IE.. and here is an article describing how to do a drag/drop upload in Firefox http://straxus.javadevelopersjournal.com/creating_a_mozillafirefox_drag_and_drop_file_upload_script_p.htm

There isn't a generic way of doing this that will work for all browsers with javascript - but you could use a java applet like this: http://www.zackgrossbart.com/hackito/2007/11/28/drag-and-drop-file-uploading-made-easy/

markt
A: 

The article which shows how to support drag and drop with an applet is at:

http://www.zackgrossbart.com/hackito/dnd-file-uploading

There's another article which shows how to do this with just JavaScript. This requires HTML5, but it works well.

http://www.thecssnin]ja.com/javascript/drag-and-drop-upload