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

<cffile action="upload"

Community Beginner ,
Feb 25, 2007 Feb 25, 2007

Copy link to clipboard

Copied

Hi ,
I found while uploading a file with <cffile> like <cffile action="upload" accept="image/jpeg" , if we rename the extention of any other file format (for example .exe, .doc), its uploading the same. So is there any solution to prevent this in CF?

Thanks in advance.

TOPICS
Advanced techniques

Views

343

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
Community Expert ,
Feb 25, 2007 Feb 25, 2007

Copy link to clipboard

Copied

I cannot reproduce your scenario. When I attempt to upload a file of type .doc or .exe with the following code, I get the error message as expected. It reads

error:
Only files of type "image/jpeg,image/jpg,image/pjpeg" can be uploaded.
Verify that you are uploading a file of the appropriate type.


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
Community Beginner ,
Feb 25, 2007 Feb 25, 2007

Copy link to clipboard

Copied

Hi,

The scenario is for example in your code it will accep .jpg, .jpeg and .pjpeg files, and what if I am uploading a .exe file (for example game.exe ) after renaming to .jpg ( game.jpg ) ? I will upload the file considering it as jpg. So I need to know any how we can prevent this by checking the file format etc.

thanks

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
Community Expert ,
Feb 25, 2007 Feb 25, 2007

Copy link to clipboard

Copied

When I rename app.exe to app.jpg and use the above code, I still get the same error message. Coldfusion can apparently tell the difference.

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
LEGEND ,
Feb 25, 2007 Feb 25, 2007

Copy link to clipboard

Copied

LATEST
yes, CF does tell the difference between actual .jpg file and another
filetype renamed to .jpg extension since it looks at actual miime type
of the file, not just the extension of the file.

are you sure you are not looking at a real .jpg file that has been
uploaded to the servewr before? how does your cffile tag handle name
conflicts?

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com

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