• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

CFFile in CF8: Filename is being changed

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">
<cfoutput>#cffile.serverfile#</cfoutput><cfabort>

Open in new window

0
djrubin
Asked:
djrubin
  • 2
  • 2
1 Solution
 
_agx_Commented:
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"
0
 
djrubinAuthor Commented:
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.
0
 
_agx_Commented:
The results you're seeing suggest otherwise.  You can test/verify it using FileExists

ie
<cfoutput>#FileExists("c:\someDir\myFile.doc")#</cfoutput>
<cfoutput>#FileExists(upload_dir &"/nameOfFileYouThinkDoesntExist.ext")#</cfoutput>

0
 
djrubinAuthor Commented:
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now