Re: Cross Platform/Browser way to send PNG file to Webserver
On Mar 17, 1:55 am, "Peter Olcott" <NoS...@OCR4Screen.com> wrote:
I want to sent a 24-bit PNG file to a web service that I
will be writing. In the ideal case the user will go to my
website and click on a button that will browse their local
hard-drive for a PNG file. This file is then verified to be
24-bit on the client side. If it is 24-bit it is then sent
to the web-service. If it is not 24-bit an error message is
displayed "The PNG file selected must have 24-bit color".
To get some of that functionality on the *client-side*
(for example, to avoid the bandwidth of receiving less
than 24 bit PNGs at the server), would require an applet.
But if your client can ensure they are using a plugin2
JRE (1.6.0_10+), this can even be achieved in a sand-boxed,
The way to do that is to hook into the JNLP APIs
FileOpenService. Here is a small demo of the
file service <http://pscode.org/jws/api.html#fs>.
I also offer GIFanim, an applet that uses the same
functionality to get images to turn into animated GIFs.
Of course, a free-floating image upload app. launched
using web start could do all this since about Java 1.4,
so if it does not have to be an *embedded* applet, it
becomes more usable to more visitors.
Note that if your users are likely to want to
'cheat' the system and still upload unsuitable
images, there are ways around the applet or JWS app.,
and you would still need to do checks on the server,
but it would save most users some time, hassle and
bandwidth to know in advance that certain images
will not be accepted.