Re: Cross Platform/Browser way to send PNG file to Webserver
Peter Olcott wrote:
"Roedy Green" <see_website@mindprod.com.invalid> wrote in
message news:opl2q5ltgv3uom5lpt6ngmo4c74u410ll8@4ax.com...
On Wed, 17 Mar 2010 12:25:36 -0500, "Peter Olcott"
<NoSpam@OCR4Screen.com> wrote, quoted or indirectly quoted
someone who
said :
Would it run on the client side and work across most every
browser?
Could it be invoked from a BrowseForFile Button on my
web-page that filters for PNG files?
One more thing, I need it to send the file over HTTP.
Look at the client side HTML on any forum that lets you
select a local
image for upload. You use <input type="file" and
accept="list of
acceptable mime types".
The documentation that I have seen says that this is not
supported. I tried it and it did not use the accept list.
I've written serlvet/JSP-based apps that do HTML file uploads, with the Apache
Commons FileUpload project
<http://commons.apache.org/fileupload/>
that in turn relies on the Apache Commons IO project
<http://commons.apache.org/io/>,
on the server side.
In the world of Java Server Faces, Tomahawk
<http://myfaces.apache.org/tomahawk/index.html>
has a tag that wraps an HTML file input,
<http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_inputFileUpload.html>
As the Tomahawk documentation there reminds you,
don't forget to set the form's attribute "enctype"
to "multipart/form-data".
See "examples/web/fileupload.jsp" for an example!
This is an HTML matter; when you do an HTML '<input type="file" ... />' you
have to change the type of the enclosing form. That makes parsing the form on
the server side a little harder, but those Apache Commons libraries take all
the sting out of it.
--
Lew