Javascript 如何将文件附件拖放到浏览器中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2677565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to drag and drop file attachment into the browser?
提问by Blankman
It seems Gmail is just starting this feature, and it doesn't require you to install any plugin etc.
似乎 Gmail 才刚刚启动此功能,它不需要您安装任何插件等。
It works in both Firefox and Chrome but not IE.
它适用于 Firefox 和 Chrome,但不适用于 IE。
回答by enyo
Use dropzonejs.
使用dropzonejs。
It's a lightweight library supporting file drops by simply adding the dropzoneclass to form elements. It handles the files with HTML5 and even shows previews of images dropped into it. In incompatible browsers it falls back to a simple file upload form. Also: it looks good.
它是一个轻量级的库,通过简单地将dropzone类添加到表单元素来支持文件删除。它使用 HTML5 处理文件,甚至显示放入其中的图像预览。在不兼容的浏览器中,它退回到简单的文件上传形式。另外:看起来不错。
Have a look at it!
看看它!
Disclaimer: I wrote this library.
免责声明:我编写了这个库。
回答by Rich Bradshaw
It's using the HTML5 drag and drop API.
它使用 HTML5 拖放 API。
回答by jamone
They are using one of HTML5's features. IE doesn't support HTML 5 or standards or...
他们正在使用 HTML5 的功能之一。IE 不支持 HTML 5 或标准或...
Here is a blogthat explains the drag and drop reasonably well.
这是一个博客,可以很好地解释拖放。
回答by David Murdoch
HTML5 drag and drop API is available in the bleeding-edge browsers like the others said.
像其他人所说的那样,HTML5 拖放 API 在前沿浏览器中可用。
Google Gears(a "plugin") can add the drag'n'drop functionality (I know Google Wave used gears at least in the Google Wave dev preview) for older browsers (FF and IE). Note that gears will not be supported forever
Google Gears(一个“插件”)可以为旧浏览器(FF 和 IE)添加拖放功能(我知道 Google Wave 至少在 Google Wave 开发预览版中使用了齿轮)。请注意,不会永远支持齿轮
回答by Ali Salehi
I suppose you are looking for this http://www.plupload.com/
我想你正在寻找这个http://www.plupload.com/

