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

Checking file extensions of uploaded files

Enthusiast ,
Dec 12, 2008 Dec 12, 2008

Copy link to clipboard

Copied

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

Views

612

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks for the reply,

I took a look but couldn't find anything relevant to the issue

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Documentation