CFFile in CF8: Filename is being changed

Posted on 2011-04-28
Last Modified: 2012-05-11
Trying to upload a file to our server with the following code. Each and every file we upload gets a filename of "upload_filesX" where X is a sequential number. Why is the original filename coming across in the form submit not "sticking"?
<cfif structKeyExists(form,"AddPictureImage") and len(trim(form.AddPictureImage))>

<!--- Use the cffile tag to upload the image file. --->
<cffile action="UPLOAD" filefield="AddPictureImage" destination="#upload_dir#" nameconflict="MAKEUNIQUE">

Open in new window

Question by:djrubin
    LVL 51

    Expert Comment

    Because you're using:  nameconflict="MAKEUNIQUE">  That instructs CF to generate a unique name for the file if that file already exists.  If you want to overwrite the existing file, use nameconflict="overwrite"

    Author Comment

    But the file I'm trying to upload is not on the server. If "MakeUnique" only changes the filename IF there is a conflict, then nothing should be done.
    LVL 51

    Accepted Solution

    The results you're seeing suggest otherwise.  You can test/verify it using FileExists

    <cfoutput>#FileExists(upload_dir &"/nameOfFileYouThinkDoesntExist.ext")#</cfoutput>


    Author Comment

    Thanks... a slightly different twist to your debug suggestion does indicate that CF thinks I have that file already... trouble is I don't so I'll dive in on why it thinks I have the file.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
    This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now