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, such as image/gif and text/plain, are registered in the browser.
ColdFusion saves any uploaded file if you omit the accept attribute or specify "*/*". You can restrict the file types, as demonstrated in the following examples.
The following cffile tag saves an image file only if it is in the GIF format:
<cffile action="Upload" fileField="Form.FiletoUpload" destination="c:\uploads\" nameConflict="Overwrite" accept="image/gif">
The following cffile tag saves an image file only if it is in GIF or JPEG format:
<cffile action="Upload" fileField="Form.FiletoUpload" destination="c:\uploads\" nameConflict="Overwrite" accept="image/gif, image/jpeg">
This cffile tag saves any image file, regardless of the format:
<cffile action="Upload" fileField="Form.FiletoUpload" destination="c:\uploads\" nameConflict="Overwrite" accept="image/*">