Hi folks,
If I have an <input type="file" /> element, is there any way of
filtering the file types shown when the user clicks on the browse
button? Currently I check the file extension using client-side
scripting, then on a successful upload I check it properly on the
server-side, rejecting at any step invalid files.
This is okay in some respects, but it would be much handier if the user
only saw (for example) *.jpg files as an option in the browse dialog in
the first place.
Can this be achieved, either through scripting or otherwise?
Cheers,
--
Dylan Parry
http://electricfreedom.org -- Where the Music Progressively Rocks!
Dylan Parry wrote:
> Hi folks,
>
> If I have an <input type="file" /> element, is there any way of
> filtering the file types shown when the user clicks on the browse
> button? Currently I check the file extension using client-side
> scripting, then on a successful upload I check it properly on the
> server-side, rejecting at any step invalid files.
>
> This is okay in some respects, but it would be much handier if the user
> only saw (for example) *.jpg files as an option in the browse dialog in
> the first place.
>
> Can this be achieved, either through scripting or otherwise?
>
> Cheers,
>
HTML had an "accept" attribute for <input>....
*runs away*
*runs back*
i just checked and it's still there in XHTML. wonder what cross
platform/browser support will be.
trevor <not@home.now> wrote:
>HTML had an "accept" attribute for <input>....
>
>*runs away*
>*runs back*
>
>i just checked and it's still there in XHTML. wonder what cross
>platform/browser support will be.
Close to zero support. Very, very close to zero support.
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
Steve Pugh wrote:
> trevor <not@home.now> wrote:
>
>
> Close to zero support. Very, very close to zero support.
>
> Steve
so it would be a job for the Java people (or something even more hideous).
more hassle than i'd think it's worth. fun question though. i wonder why i
haven't heard it yet.
trevor wrote:
["accept" attribute for <input>]
> i just checked and it's still there in XHTML. wonder what cross
> platform/browser support will be.
As Steve says, it's almost zilch, which is why it isn't something I can
use. I should have mentioned that I had seen that "solution" already,
but figured that others would know (like myself) that the support just
isn't there... never make assumption! :)
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
Dylan Parry wrote:
> This is okay in some respects, but it would be much handier if the user
> only saw (for example) *.jpg files as an option in the browse dialog in
> the first place.
What about these files:
picture_which_i_want_to_upload_to_dylan.jpeg
picture_which_i_want_to_upload_to_dylan.my_jpeg_image
picture_which_i_want_to_upload_to_dylan
??
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Fleeing from the madness of the jungle
Dylan Parry <usenet@dylanparry.com> stumbled into news:alt.www.webmaster
and said:
> Hi folks,
>
> If I have an <input type="file" /> element, is there any way of
> filtering the file types shown when the user clicks on the browse
> button? Currently I check the file extension using client-side
> scripting, then on a successful upload I check it properly on the
> server-side, rejecting at any step invalid files.
>
> This is okay in some respects, but it would be much handier if the user
> only saw (for example) *.jpg files as an option in the browse dialog in
> the first place.
>
> Can this be achieved, either through scripting or otherwise?
AIUI you have no control over the 'browse' functionality - tis a security
feature.
--
William Tasso
http://williamtasso.com/words/what-is-usenet.asp
Toby Inkster wrote:
> What about these files:
>
> picture_which_i_want_to_upload_to_dylan.jpeg
> picture_which_i_want_to_upload_to_dylan.my_jpeg_image
> picture_which_i_want_to_upload_to_dylan
Not remotely interested in allowing people to upload such files. The
file types I will allow people to upload are a proprietary type called
*.shp, which are a type of file that contain mapping data. They only
ever come as *.shp and are completely invalid in any other extension.
This is for a completely closed system, so Joe Public isn't going to be
using it. The idea behind using a filter is so that I personally don't
have to trawl through a directory of files that aren't *.shp files.
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
William Tasso wrote:
> AIUI you have no control over the 'browse' functionality - tis a security
> feature.
Oh well. I personally can't see how the ability to filter out file types
can be a security feature when done by the browse dialog in a web
browser as opposed to the same dialog in Office, Photoshop or any other
program that does this.
--
Dylan Parry
http://electricfreedom.org -- Where the Music Progressively Rocks!
Dylan Parry wrote
> Toby Inkster wrote:
>
>
> Not remotely interested in allowing people to upload such files. The
> file types I will allow people to upload are a proprietary type called
> *.shp, which are a type of file that contain mapping data. They only
> ever come as *.shp and are completely invalid in any other extension.
>
> This is for a completely closed system, so Joe Public isn't going to
be
> using it. The idea behind using a filter is so that I personally don't
> have to trawl through a directory of files that aren't *.shp files.
If you have control of the machines doing the uploading, can't you make
the "Browse" facility on the machine default to a particular
directory/file type?
--
Charles Sweeney
http://CharlesSweeney.com