JavaScript中的“文件对话框取消”事件

时间:2022-11-09 00:03:29

I have a file input:

我有一个文件输入:

<input type=file id=file onchange='foo(this.files)'/>

Function 'foo' is called only when user chooses some file in the file upload dialog and clicks "OK". Is there any event that will be fired when user clicks "cancel" button in the dialog? HTML5-only solutions are OK.

仅当用户在文件上载对话框中选择某个文件并单击“确定”时,才会调用函数“foo”。当用户点击对话框中的“取消”按钮时,是否会触发任何事件?仅HTML5解决方案是可以的。

1 个解决方案

#1


-1  

I think that the best way if you can change a bit your code, is adding plugins to add files, for example:

我认为,如果您可以更改代码,最好的方法是添加插件来添加文件,例如:

http://swfupload.org/

http://swfupload.org/

or

要么

http://www.uploadify.com

http://www.uploadify.com

these are the more common, I'd work with the first and I had no problems.

这些更常见,我会与第一个一起工作,我没有遇到任何问题。

This will not do exactly what you want, but you can add files in a queue and then cancel them, and you can capture this event...

这不会完全符合您的要求,但您可以在队列中添加文件然后取消它们,您可以捕获此事件......

I know that is not what you was looking for, but is the best solution I can give you

我知道这不是你想要的,但却是我能给你的最佳解决方案

good luck! I hope I've helped you

祝你好运!我希望我帮助过你

#1


-1  

I think that the best way if you can change a bit your code, is adding plugins to add files, for example:

我认为,如果您可以更改代码,最好的方法是添加插件来添加文件,例如:

http://swfupload.org/

http://swfupload.org/

or

要么

http://www.uploadify.com

http://www.uploadify.com

these are the more common, I'd work with the first and I had no problems.

这些更常见,我会与第一个一起工作,我没有遇到任何问题。

This will not do exactly what you want, but you can add files in a queue and then cancel them, and you can capture this event...

这不会完全符合您的要求,但您可以在队列中添加文件然后取消它们,您可以捕获此事件......

I know that is not what you was looking for, but is the best solution I can give you

我知道这不是你想要的,但却是我能给你的最佳解决方案

good luck! I hope I've helped you

祝你好运!我希望我帮助过你