开发者

How to upload files with java applet?

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 开发者_JAVA百科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:)


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.


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"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜