< input type ='file'/>>替换onchange事件 [英] alternate to onchange event in <input type='file' />
问题描述
问题是,这是行不通的,如果用户选择在同一个文件连续两次,onchange不会触发(这是有道理的,因为没有任何改变),但在我的情况下,我也很重要的捕获该事件,获取路径和上传。
编辑
(与清除< input type ='file'/>使用jQuery ,不确定是否应该将其解析为重复)
您可以删除输入并使用javascript创建一个相同的输入 - 新的输入为空。
到现在为止,评论是不相关的)
Seems really a simple thing but can't figure it out. I've been using the onchange event on element and it works well. Once the user browses and selects a file, I get the path and upload it using a my custom js function.
The problem is this doesn't work if a user selects the same file twice in a row, the onchange doesn't fire (which makes sense since nothing changed) but in my case it's important for me to capture that event too, get the path and upload.
Edit
(Similar to Clearing <input type='file' /> using jQuery, not sure if I should resolve this as duplicate)
You can just remove the input and create an identical one with javascript - the new one will be empty.
(edited answer to be straight to the point, comments are irrelevant now)
这篇关于< input type ='file'/>>替换onchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!