使用较少的javascript拖放上传 [英] making drag and drop upload with less javascript
问题描述
我想为我的网站制作上传文件,因此用户可以轻松地将文件拖放到其上。
I'm trying to make an upload holder for my website, so users can easily drag and drop a file on it.
有很多图书馆
这个(思考)...
我把一个文件输入
并设置 width
和 height
。
用户拖动一个文件, onchange
事件将工作。
now when my user drag a file on it, onchange
event will work.
但我想隐藏浏览按钮,两种方式:
but I want to hide browse button and there is two way:
设置 0 opacity
(它在某些浏览器中不起作用)
set 0 opacity
.(it is not working in some browsers)
设置隐藏的可见性
(这种想法无效)
,还有什么我可以尝试?
help me, what else I can try?
推荐答案
将表单放在隐藏的iframe。对目标使用普通div。当文件被删除时,捕获事件并更新输入,然后作为发送提交。结果是通过文件拖放进行类似ajax的上传。
Put the form on a hidden iframe. Use an ordinary div for the target. When the file is dropped, catch the event and update the input, then submit as post. The result is ajax-like uploading via file drag and drop.
这篇关于使用较少的javascript拖放上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!