Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CF9 - best way to restrict file type for uploads??

LEGEND ,
Feb 08, 2013 Feb 08, 2013

Hello, everyone.

We're using CF9 in both dev and production environments, with little chance of upgrading to CF10 anytime in the near future (it's my understanding CF10 does have a way of detecting a file mimetype that CF9 doesn't have.)

What is the best way to restrict uploads to specific file types in CF9?  We just need to limit uploads to primary Office (doc(x), ppt(x), xls(x), etc.), PDFs, and gif/jpg (no bmps, pngs, etc.)

Obviously, just detecting file extension is fruitless.

Thank you,

^_^

770
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 11, 2013 Feb 11, 2013

I'm currently using the unreliable method of checking the file extension.  Is there a better way in CF9?

Thank you,

^_^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2013 Feb 11, 2013

What about just using the accept attribute? That's what it's there for. Just something like:

<cffile

action="upload"

filefield="fileContent"

accept="application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, image/gif, application/pdf"

...

...

etc.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 11, 2013 Feb 11, 2013
LATEST

Because according to the documentation, the accept parameter relies upon the browser to provide that information.

I'd rather detect the mimetype, then go from there.  I heard that this is in place in CF10, but not CF9.  I was hoping someone would have written a UDF for CF9.

^_^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources