访问INPUT TYPE ="文件"从Java小程序的完整路径 [英] Accessing input type="file" full path from a Java applet

查看:179
本文介绍了访问INPUT TYPE ="文件"从Java小程序的完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能从使用netscape.javascript JSObject API一个applet访问HTML DOM。
不过,如果我查询在某些浏览器中输入类型=文件的值,(歌剧)我得到一个完整路径选定的文件,但其他浏览器(火狐,Chrome)只是一个文件名的不路径

It is possible to access HTML DOM from an applet using netscape.javascript JSObject API. However, if I query a value of a input type="file", on some browsers (Opera) I get a full path to a selected file, but on other browsers (Firefox, Chrome) just a file name without path.

是否有可能,有一个HTML输入类型=文件,找出完整路径从Java小程序在它选择的文件?

Is it possible, having an HTML input type="file", to figure out the full path to the file selected in it from a Java applet?

为什么我烦的原因:签名的Applet可以访问文件系统和浏览器文件选择器是不是更好了大量的Java Swing有一个

The reason why I bother: signed applets can access file system, and browsers' file selectors are a lot nicer than Java swing one.

推荐答案

您不能。你通过HTML / JS(和浏览器)的安全限制的约束。据官方统计,输入类型=文件的值应仅返回文件名,绝不文件路径。然而,我很惊讶,歌剧返回的完整路径,即因为MSIE是我知道是谁做的唯一的一个。

You cannot. You're restricted by HTML/JS (and browser) security limitations. Officially, the value of input type="file" should only return the filename, never the filepath. I am however surprised that Opera returns the full path, namely because MSIE was the only one I knew of who did it.

但是,正如你已经运行的小程序,你为什么不只是利用自己的能力?您可以使用 Swing的的JFileChooser 来选择一个文件,正是因为你可以用HTML做输入类型=文件

But as you're already running an applet, why don't you just make use of its capabilities? You can use Swing's JFileChooser to select a file, exactly as you can do with HTML input type="file".

这篇关于访问INPUT TYPE ="文件"从Java小程序的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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