Click here to get back home

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
magix 02-21-2008
---> Re: Rik Wasmus02-21-2008
| `--> Re: Rik Wasmus02-21-2008
---> Re: GTalbot02-21-2008
  |--> Re: Jonathan N. Lit...02-21-2008
  |--> Re: Stephan Bird02-22-2008
  `--> Re: Jukka K. Korpel...02-22-2008
Get Chitika Premium
Posted by Stephan Bird on February 22, 2008, 2:49 am
Please log in for more thread options
On Thu, 21 Feb 2008 15:19:30 -0800 in
b0f69bfa-5ce3-46f4-a22c-960a64330b16@e60g2000hsh.googlegroups.com GTalbot

>
>> how can I limit the file type to be only jpg and gif extension, when
>> the browse window open ?
>
> accept = content-type-list [CI]
> This attribute specifies a comma-separated list of content types
> that a server processing this form will handle correctly. User agents
> may use this information to filter out non-conforming files when
> prompting a user to select files to be sent to the server (cf. the INPUT
> element when type="file").
> http://www.w3.org/TR/html4/interact/forms.html#adef-accept
>
> So:
>
> <input type="file" accept="image/jpg, image/gif">
>
> Not tested.

This seems to rely on MIME types (amongst other things), so in principle
could I send a file abc which is encoded as a gif or jpeg and have it
accepted? If the string above worked and no others, what of image/jpeg or
image/jpe - are these also encoded by the same codex? To the strict
letter of the OP, perhaps all you need to do is check the last three
letters of the filename, but that may run into issues with things like
def.gif which is actually an executable..?

Stephan

--
Stephan Bird MChem(Hons) AMRSC
stephan.j.bird@mad.scientist.comREMOVE
Currently in Caernarfon, Wales.

Posted by Jukka K. Korpela on February 22, 2008, 3:27 am
Please log in for more thread options
Scripsit Stephan Bird:

>> <input type="file" accept="image/jpg, image/gif">
>>
>> Not tested.
>
> This seems to rely on MIME types (amongst other things),

MIME types would be the right concept to be used, but as Jonathan
mentioned, this attribute has not been implemented. There's a lot in
file input that exists only in the original plans and later
specifications and was ignored or distorted by implementors; see
http://www.cs.tut.fi/~jkorpela/forms/file.html

> so in
> principle could I send a file abc which is encoded as a gif or jpeg
> and have it accepted?

In principle, yes. However, image/jpg is an unregistered MIME type; this
was probably a typo, and image/jpeg was intended. If image/jpg were
actually used, it would be ignored by a conforming implementation, and
GIF images only would be accepted.

> If the string above worked and no others, what
> of image/jpeg or image/jpe - are these also encoded by the same
> codex?

The correct MIME type name is image/jpeg, and image/jpg and image/jpe
are undefined and to be ignored. However, a quality implementation would
issue a warning and prompt the user for corrective action and send a
message to the page author, if specified in metadata, and then cows
would fly.

> To the strict letter of the OP, perhaps all you need to do is
> check the last three letters of the filename, but that may run into
> issues with things like def.gif which is actually an executable..?

The last three letters of a filename are no magic. Programs may assume
some mapping from them to MIME types, but there is no specification on
this, and there is great variation in practice.

A proper implementation of accept="..." would require, more or less, a
file system where each file has a descriptor indicating its properties,
such as MIME type (and character encoding, etc.). Simple filtering by
filename extension would be easy to implement but somewhat problematic;
in practice, implementors just didn't bother.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap