This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Webmaster forum > June 2006 > Filtering valid file types





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Filtering valid file types
Dylan Parry

2006-06-08, 7:27 pm

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!
trevor

2006-06-08, 7:27 pm

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

2006-06-08, 7:27 pm

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/>
trevor

2006-06-08, 7:27 pm

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

2006-06-08, 7:27 pm

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
Toby Inkster

2006-06-08, 7:28 pm

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

William Tasso

2006-06-08, 7:28 pm

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
Dylan Parry

2006-06-08, 7:28 pm

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
Dylan Parry

2006-06-08, 7:28 pm

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!
Charles Sweeney

2006-06-08, 7:28 pm

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
Dylan Parry

2006-06-08, 7:28 pm

Charles Sweeney wrote:

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


Doesn't seem like you can. Of course I can type "*.shp" when I have
clicked on the browse button, but to do that every time I (or anyone
else using the system) wants to upload something is a bit of a chore.

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
Martin Jay

2006-06-08, 7:28 pm

In message <zMkhg.86157$IZ2.31182@dukeread07>, trevor <not@home.now>
writes
>Dylan Parry wrote:
>
[color=darkred]
>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.


I'm tempted to say none, but you never know...

It seems to be unimplemented because of security concerns.
--
Martin Jay
Phone/SMS: +44 7740 191877
Fax: +44 870 915 2124
Charles Sweeney

2006-06-08, 7:28 pm

Dylan Parry wrote

> Charles Sweeney wrote:
>
>
> Doesn't seem like you can. Of course I can type "*.shp" when I have
> clicked on the browse button, but to do that every time I (or anyone
> else using the system) wants to upload something is a bit of a chore.


Indeed. I'm guessing that you can't keep the .shp (shape?) files in a
directory of their own? Whould it be too much of a chore to make a
seperate directory and have copies of the .shp files in there, existing
ones or when new ones are created.

--
Charles Sweeney
http://CharlesSweeney.com
Dylan Parry

2006-06-08, 7:28 pm

Charles Sweeney wrote:

> Indeed. I'm guessing that you can't keep the .shp (shape?) files in a
> directory of their own? Whould it be too much of a chore to make a
> seperate directory and have copies of the .shp files in there, existing
> ones or when new ones are created.


The problem is that each .shp file has four accompanying files that are
created at the same time (.shx, .sbn, .prj, .dbf) and all live in the
same place as the .shp file. They are non-optional, and without them the
..shp file doesn't work properly, so in order to upload the .shp file,
the user must then upload the remaining four files too. There may be
several hundred of each file type in the directory, and separating them
out really would be a chore.

--
Dylan Parry
http://electricfreedom.org -- Where the Music Progressively Rocks!
Charles Sweeney

2006-06-08, 7:28 pm

Dylan Parry wrote

> Charles Sweeney wrote:
>
>
> The problem is that each .shp file has four accompanying files that are
> created at the same time (.shx, .sbn, .prj, .dbf) and all live in the
> same place as the .shp file. They are non-optional, and without them the
> .shp file doesn't work properly, so in order to upload the .shp file,
> the user must then upload the remaining four files too. There may be
> several hundred of each file type in the directory, and separating them
> out really would be a chore.


Yikes! Good luck!

--
Charles Sweeney
http://CharlesSweeney.com
trevor

2006-06-08, 7:28 pm

Martin Jay wrote:

> In message <zMkhg.86157$IZ2.31182@dukeread07>, trevor <not@home.now>
> writes
>
>
> I'm tempted to say none, but you never know...
>
> It seems to be unimplemented because of security concerns.


no, it's implemented, but it's not part of the DOM (a point of significance
lost in this thread) so it's not something we can work with across
platforms. the .NET crowd probably had 20 ways of doing this 5 years ago
before they regretted your aptly mentioned security concerns. which was why
i brought up Java (equally lost in thread) because you need a local agent
and your alternatives are Java, another user-installed local agent,
Microshaft's Active-X or sucking your thumbs.
William Tasso

2006-06-08, 7:28 pm

Fleeing from the madness of the jungle
Dylan Parry <usenet@dylanparry.com> stumbled into news:alt.www.webmaster
and said:

> Charles Sweeney wrote:
>
>
> The problem is that each .shp file has four accompanying files that are
> created at the same time (.shx, .sbn, .prj, .dbf) and all live in the
> same place as the .shp file. They are non-optional, and without them the
> .shp file doesn't work properly, so in order to upload the .shp file,
> the user must then upload the remaining four files too. There may be
> several hundred of each file type in the directory, and separating them
> out really would be a chore.


Have you considered writing a client side helper app that uses FTP
(perhaps) to upload the files?

--
William Tasso

http://williamtasso.com/words/what-is-usenet.asp
Dylan Parry

2006-06-08, 7:28 pm

William Tasso wrote:

> Have you considered writing a client side helper app that uses FTP
> (perhaps) to upload the files?


That is a possibility for later work. At the moment, the entire system
has been written and works well, so I don't want to go back to the
drawing board quite yet. I was merely titivating with bells and whistles
on this really. I may consider writing a custom app to do the job in the
future though.

--
Dylan Parry
http://electricfreedom.org -- Where the Music Progressively Rocks!
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews