This content has been marked as final. Show 4 replies
Yes CFFile has several actions. Append, Copy, Delete, Move, Read,
ReadBinary, Rename, Upload and Write.
With these combinations you should be able to do what you want.
> Hi All,
> I'm developing a knowledgebase and one of the things it allows a user to do is
> upload a document to a certain folder on the web server. I'm using a cffile
> with the upload mode and unique file name functionality which that if there is
> already a file with that name it changes the name of the file. The problem I'm
> having is within the approval stage to this kb. I need to allow the approver
> (user) to change the location of the file by cutting the file and paste it in a
> new folder and if the document already exists renaming it programmatically. I
> know the cffile upload has the ability to create a uniquefile name but how
> about cut and pasting? Any ideas?
Yeah but can cut and paste cffile function allow me to create new unique file names if the file exists in the folder that I'm trying to move it to?
Looking at the documentation, does not look like the write and/or move
actions will automatically rename the file if an existing file does
exist. Looks like it is up to you to control this. You can use the
<cfdirectory> tag to read the directory and check for the existence of
the file in question, then take appropriate action in choosing the name
to write the file under.
> Yeah but can cut and paste cffile function allow me to create new unique file names if the file exists in the folder that I'm trying to move it to?
allow the approver (user) to change the location of the file by cutting the file and paste it in a new folder and if the document already exists renaming it programmatically.
One way to implement Ian Skinner's suggestion is as follows. Use <cfdirectory> to check whether a file of that name exists in the old (upload) folder and in the new folder. If so, modify the file name (just a string) and check again. Keep checking until it is sure the file name is unique for both the old folder and the new. Append the new name to the full path string. Use <cffile action="rename"> and/or <cffile action="move"> to rename the file at the old folder, then move it to the new.