2

I created a Java applet for my web page that creates an image file. I want users to be able to run the applet and create unique images, click a button, and have the image they created be saved to the web server.

I think I have the code down for writing the image to a URLconnection in the Java applet itself after having successfully written a file while running the applet on my system rather than the web page and saving a file to the local disk, and then altering a few things to write to a URLConnection instead of to the local disk (although we shall see how that works too).

I am now trying to write a cgi script in perl that takes the image output from the URLConnection and writes the image to a file on my web server (note: I am a newbie to perl). I have found many examples of how to do something similar with simple text coming from an applet and then writing it to a text file, but I want to know how to apply the same concept to an image. Particularly, how do I read in the image? I've seen text input get read by using read(STDIN, $some_variable)--does the same thing work with an image? Likewise, how do I write the image file? What function do I use?

Thanks for your help. I know that I am rather naive about all of this.

somedude
  • 21
  • 1

1 Answers1

1

There is no problem at server side if you use the CGI module (see the "PROCESSING A FILE UPLOAD FIELD" section), which can help you. And it's important to adapt your applet in order to send the file as if you were using a HTML form with an input type file (so you need to use the POST verb in HTTP protocol, and encode properly the request). This link may helps.

Community
  • 1
  • 1
Miguel Prz
  • 13,227
  • 26
  • 36