简体   繁体   English

需要将文件拖放到html中

[英]Need to drag and drop a file in html

I am having a html file containing a div tag.While viewing this html in browser,I want to drag a file from my desktop and drop it in this html file(in browser). 我有一个包含div标签的html文件。在浏览器中查看此html时,我想从桌面上拖动一个文件并将其放在该html文件中(在浏览器中)。 Then the dragged file(ex. jpeg) path should display in the div portion.How to do this in javascript. 然后拖动的文件(例如jpeg)路径应显示在div部分中。如何在javascript中执行此操作。

You won't (AFAIK) be able to do that with pure JS in an HTML 4.0 environment. 您(AFAIK)将无法在HTML 4.0环境中使用纯JS做到这一点。 You'll either need Silverlight, Flash or (heaven forbid) an ActiveX controller. 您将需要Silverlight,Flash或(禁止使用天堂)ActiveX控制器。 HTML 5.0 has DnD capabilities (I believe) but not all browsers suport it. HTML 5.0具有DnD功能(我相信),但并非所有浏览器都支持它。

http://html5doctor.com/native-drag-and-drop/ http://html5doctor.com/native-drag-and-drop/

that should give you some idea about how it works :) 那应该给你一些关于它如何工作的想法:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM