From: Roedy Green on
On Wed, 17 Mar 2010 12:25:36 -0500, "Peter Olcott"
<NoSpam(a)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".

Alternatively, you could use a signed Applet with a FileChooser with a
filter based on extensions to upload the file and send it.
--
Roedy Green Canadian Mind Products
http://mindprod.com

Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question.
~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming.
From: Peter Olcott on

"Roedy Green" <see_website(a)mindprod.com.invalid> wrote in
message news:opl2q5ltgv3uom5lpt6ngmo4c74u410ll8(a)4ax.com...
> On Wed, 17 Mar 2010 12:25:36 -0500, "Peter Olcott"
> <NoSpam(a)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.

>
> Alternatively, you could use a signed Applet with a
> FileChooser with a
> filter based on extensions to upload the file and send it.

Can this send a file over HTTP ?

> --
> Roedy Green Canadian Mind Products
> http://mindprod.com
>
> Responsible Development is the style of development I
> aspire to now. It can be summarized by answering the
> question, "How would I develop if it were my money?" I'm
> amazed how many theoretical arguments evaporate when faced
> with this question.
> ~ Kent Beck (born: 1961 age: 49) , evangelist for extreme
> programming.


From: Lew on
Peter Olcott wrote:
> "Roedy Green" <see_website(a)mindprod.com.invalid> wrote in
> message news:opl2q5ltgv3uom5lpt6ngmo4c74u410ll8(a)4ax.com...
>> On Wed, 17 Mar 2010 12:25:36 -0500, "Peter Olcott"
>> <NoSpam(a)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
From: Roedy Green on
On Wed, 17 Mar 2010 19:32:55 -0500, "Peter Olcott"
<NoSpam(a)OCR4Screen.com> wrote, quoted or indirectly quoted someone who
said :

>> 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.

In that case, you have to do your filtering at the server, rejecting
anything you don't like. You might experiment with the mime types in
the HTTP header for the enclosing page to see if they work to filter.
To get just a particular flavour of PNG, you will have to filter at
the server anyway.

>> Alternatively, you could use a signed Applet with a
>> FileChooser with a
>> filter based on extensions to upload the file and send it.
>
>Can this send a file over HTTP ?

An applet can do anything a browser can. The catch is, nearly
anything interesting requires signing the applet. See
http://mindprod.com/jgloss/signedapplets.html
The advantage is the user will see the possible choices pre-filtered
so there will not be the distraction of unsuitable gif files, for
example.

--
Roedy Green Canadian Mind Products
http://mindprod.com

Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question.
~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming.
From: Andrew Thompson on
On Mar 17, 1:55 am, "Peter Olcott" <NoS...(a)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.

> Can this be done in either JavaScript or Java?

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,
embedded applet.

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.
<http://pscode.org/gifanim/#run>

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.

--
Andrew T.
pscode.org
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Hamming Distance
Next: "this" pointer in a sublcass