如何用java小程序上传文件?
我知道有人问过类似的问题,但我已经搜索了几个小时,但到目前为止还没有找到可行的解决方案。
我有一个 Java 小程序,它将是一个类似“绘画”的应用程序。因此,我需要用户能够从他们的文件系统上传图像。我首先尝试使用 JFileChooser,它在 eclipse 环境中工作得很好。但是,当放在网上时,我收到“java.security.AccessControlException:访问被拒绝”异常。
我在想也许在小程序中我可以调用一个脚本(位于我的服务器上),它会提示用户选择一个文件 - 但我不知道如何做到这一点。我正在使用 zymic 网络托管,因此唯一支持的脚本语言是 PHP。
我也尝试签署小程序。由于我不想花钱买证书,所以我对小程序进行了自签名。当我尝试运行它时,出现错误,指出“发布者无法通过可信来源验证”。
任何帮助将不胜感激。 - 谢谢:)
I know similar questions have been asked but i have searched for hours and as of yet have not come up with a workable solution.
I have a Java applet which will be a "paint" like application. So, I need the user to be able to upload images from their file system. I first tried using a JFileChooser which works great in the eclipse environment. However, when put online i get a "java.security.AccessControlException: access denied" exception.
I was thinking that perhaps within the applet i could call a script (located on my server) which would prompt the user to select a file - but i have no idea how to do this. I am using zymic web hosting, so the only supported scripting language is PHP.
I also tried signing the applet. Since i don't want to spend money on certificates, i self signed the applet. When i tried running it, I got an error stating "The Publisher Cannot Be Verified By A Trusted Source".
Any help would be greatly appreciated. - Thanks:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
受信任的小程序肯定可以从本地文件系统加载文件。由自签名小程序生成的“发布者无法通过可信来源验证”消息非常繁重且麻烦。可怕(出于好的原因),但如果用户同意,它就可以正常工作。
这是一个小演示。正是如此。
自“下一代”插件以来,即使是沙盒小程序也可以访问本地文件系统。有关更多详细信息,请参阅 Applet 标记信息页面 上的最后 2 个链接。
这是使用下一代文件功能的小程序。
A trusted applet can most certainly load files from the local file-system. The "Publisher Cannot Be Verified By A Trusted Source" message that is produced by self-signed applets is onerous & scary (for good reason), but if the user OKs it, it works just fine.
Here is a small demo. of exactly that.
Since the 'Next Generation' Plug-In, even sand-boxed applets can access the local file system. See the last 2 links on the Applet tag info page for further details.
Here is an applet that uses the Next Generation file abilities.
出于安全原因,未签名的小程序无法访问文件系统。
这里有一个关于使用 PHP 上传文件的教程,
也许您可以将其应用到您的页面中命令允许上传文件,然后使用小程序从 Web 服务器加载该文件。
请记住该示例末尾“php - 文件上传:安全实践”部分下的警告
Unsigned applets can not access the file system for security reasons.
There is a tutorial about uploading files using PHP here
Maybe you can work that into your page in order to allow the file to be uploaded and then load it from your web server with the applet.
Do keep in mind the warning at the end of that example under the section "php - file upload: safe practices"