gwt文件上传 [英] gwt fileupload

查看:104
本文介绍了gwt文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想触发一个隐藏的FileUpload小部件上的浏览按钮的点击。
以下代码可以在IE 6+上正常工作,但在FireFox中不起作用。



pre $ final $ FileUpload upload =新的FileUpload();

upload.setVisible(false);
upload.setName(uploadFormElement);
panel.add(上传);
$ b $ panel.add(new Button(Select File,new ClickListener()
{public void onClick(Widget pSender)
{jsClickUpload(upload.getElement()); }}));

native void jsClickUpload(Element pElement)/ * - {pElement.click(); } - * /;

如何在FireFox(以及其他浏览器)中实现相同功能?

解决方案

可以在这里阅读解决方案: $ b

http://www.quirksmode.org/dom/inputfile.html



在最后一段中:


click()方法允许您
模拟表单字段上的点击。
复选框被切换,收音机
被选中,等等。不幸的是,
Mozilla和Opera没有将这个
方法添加到文件上传字段中。我想知道
为什么加入它并不是真正的
安全风险,因为可能发生
的最坏情况是文件选择
窗口弹出。



I would like to trigger a click on the browse button on a hidden FileUpload widget. The following code works fine on IE 6+, but doesn't work in FireFox.

final FileUpload upload = new FileUpload(); 

upload.setVisible(false);
upload.setName("uploadFormElement"); 
panel.add(upload);

panel.add( new Button("Select File", new ClickListener()
{ public void onClick(Widget pSender) 
{ jsClickUpload( upload.getElement() ); } }));

native void jsClickUpload( Element pElement ) /*-{ pElement.click(); }-*/; 

How can I achieve the same in FireFox (and possibly other browsers)?

解决方案

The solution can be read here:

http://www.quirksmode.org/dom/inputfile.html

in the last paragraph:

The click() method allows you to simulate a click on a form field. Checkboxes get toggled, radios selected, and so on. Unfortunately Mozilla and Opera haven't added this method to file upload fields. I wonder why, adding it is not really a security risk since the worst that can happen is that the file selection window pops up.

这篇关于gwt文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆