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

Checking file extensions of uploaded files

Enthusiast ,
Dec 12, 2008 Dec 12, 2008
I am uploading an image using the code below, is there an easy way to tell if the server has received a JPG or a GIF?

<input type="file" name="image_1" size="90" style="background-color: #ededed; border-width: 1px; border-color: #ffcccc; color: black; font-size: 9pt;">

TOPICS
Advanced techniques
685
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
Participant ,
Dec 12, 2008 Dec 12, 2008
I found this site that checks the extension file of the uploaded file.

http://www.bennadel.com/blog/834-Ask-Ben-Upload-And-Email-File-Using-ColdFusion.htm

Hope it helps
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
Enthusiast ,
Dec 12, 2008 Dec 12, 2008
Thanks for the reply,

I took a look but couldn't find anything relevant to the issue
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
Valorous Hero ,
Dec 12, 2008 Dec 12, 2008
LATEST
> I took a look but couldn't find anything relevant to the issue

I only skimmed the entry. But it appears to use the uploaded file's extension to determine which file types are allowed. For example, this line tries to verify the file is a PDF, RTF or word document.

ie
<cfif NOT ListFindNoCase( "pdf,doc,rtf", CFFILE.ServerFileExt )>
....

You could use a similar check to determine if the uploaded file is a GIF or JPG (.jpg or .jpeg). Bear in mind file extensions can be changed. So extension alone does guarantee a file is of a particular type. It is more likely, but not a guarantee.
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