Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: incrediBILL
What purpose does the accept attribute serve during a file upload? For example:
<input name="userfile" type="file" accept="application/pdf" />
OK, then is it a server-side parameter? Seems Macromedia CF does something with it. This is what I've found so far:
There is no functionality implemented for this property unless defined by the author.
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.
Not all browsers support MIME type associations.
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.
[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]