homepage Welcome to WebmasterWorld Guest from 54.166.100.8
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
HTML <input type="file"> accept attribute
What purpose does it serve during file upload?
coopster




msg:575398
 9:00 pm on Oct 3, 2003 (gmt 0)

There was a discussion started at the tail end of this PHP forum thread regarding file uploads [webmasterworld.com] and it started drifting into more of an HTML topic rather than server-side processing.

What purpose does the accept attribute serve during a file upload? For example:

<input name="userfile" type="file" accept="application/pdf" />

The best I can figure so far is that user agents may use this to filter out non-conforming files. Yeah, right. Try it once. I tested IE6.1 and NN7.1 and either one will allow me to select anything I want, not just a .pdf file. Which is fine, I run lots of editing on the server side anyway.

OK, then is it a server-side parameter? Seems Macromedia CF does something with it. This is what I've found so far:


Microsoft:


There is no functionality implemented for this property unless defined by the author.

http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/accept.asp



Macromedia:


Controlling the type of file uploaded

For some applications, you might want to restrict the type of file that is uploaded. For example, you might not want to accept graphic files in a document library.

You use the accept attribute to restrict the type of file that you allow in an upload. When an accept qualifier is present, the uploaded file's MIME content type must match the criteria specified or an error occurs. The accept attribute takes a comma-separated list of MIME data names, optionally with wildcards.

A file's MIME type is determined by the browser. Common types, like image/gif and text/plain, are registered in your browser.

Note

Not all browsers support MIME type associations.

http://livedocs.macromedia.com/coldfusion/5.0/Developing_ColdFusion_Applications/manageFiles3.htm


Looks like it is used moreso on the server-side as opposed to being something to use or rely on in the user agent. If anybody has broader knowledge of the accept attribute, by all means enlighten us!

 

MonkeeSage




msg:575399
 9:20 pm on Oct 3, 2003 (gmt 0)

The REC says...

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

Mabye they mean they made is so user agents could do that but none actually do, heh. ;)

Or mabye it is used to set the filter mask for the file dialog (i.e., the "All files (*.*)" part) or something like that...just guessing...never even know about it before just now.

Jordan

[edit:] I just tried this:

<input name="userfile" type="file"
accept="<?php echo $_SERVER['HTTP_ACCEPT'];?>" />

And it gave me a nice big comma-separated list, but Firebird 0.6.1, Opera 7 and IE 6 just had *.* as the default mask in the dialog, heh. [/edit]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved