Skip to main content
Inspiring
June 16, 2006
Question

cffile upload - cut and paste

  • June 16, 2006
  • 2 replies
  • 551 views
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?

Thanks!
James
This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
June 18, 2006
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.



Inspiring
June 16, 2006
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.

jimmy.hunt wrote:
> 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?
>
> Thanks!
> James
>
Inspiring
June 16, 2006
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?

Thanks!
James