Link to home
Start Free TrialLog in
Avatar of Jonc
Jonc

asked on

Loading image from file.

I've been loading image into memory using getImage(URL, String) which must be run from an applet. I now want to perform this code elsewhere, meaning I can use URL bit, besides I want to access my local directory. What methods exist to perform this operation.

Thanks

Jonc
Avatar of imladris
imladris
Flag of Canada image

An applet can only access the server from which it was loaded.
If it was loaded from across the wire, you can only access that URL. If it loaded from the local machine, it can access a file on the local machine, but it can then not access a URL pointing to another machine.
Avatar of Jonc
Jonc

ASKER

I thought it I signed the file with a digital signature, I could access the local files. Anyway, assuming I can't access another machine, how do I load a file from the local machine from a method that does not extend Applet as getImage is from Applet.

i.e. I have a class, extends applet, then I have a class that extends frame and wants to display the image. I really want the user to select using the FileDialog, which is what I had until I moved the code from the class extending Applet.
 You can get permission to do that through digital signature in netscape and in the explorer. In the explorer you can also give an applet permissions to do almost anything . to do that  perform the following:  use view -> internet options -> security tab -> trusted site zone -> add sites -> (write the servers address) -> Add -> OK -> set Custom security level -> Settings... -> scroll to Java permissions ->   Check the "Custom" Checkbox -> Click the "Java Custom Settings..." -> Select the "Edit Permission" tab. -> Under "Run Unsigned Content" Check the "Enable" Checkbox -> Click "OK" -> Click "OK" -> Click Apply -> Click "OK".
 
   Once you have a trusted applet, all you have to do is use a URL the same way you did before but direct it to the local disk (like   new String urlname("file:///images/king.jpg");  ). Use this new URL instead of the old one and load the image the same way.

Avatar of Jonc

ASKER

Excellent, just what I wanted, how do I change this to grade your response qadio?

Do I reopen and you type in something irrelevant and I grade you on that?
Reject the previously given answer, and then I'll write an answer here.

Thank you, learned something here.

It is perhaps worth noting consequences though. If you aren't the only user of the code, then anyone else who wants to use it will have to have the relevant stuff on their drive and, more importantly, bypass their security as indicated above. This, of course, opens them up to malicious applets.

ASKER CERTIFIED SOLUTION
Avatar of gadio
gadio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial