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

cffile upload - cut and paste

Explorer ,
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

445

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 ,
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

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
>

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
Explorer ,
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

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

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 ,
Jun 16, 2006 Jun 16, 2006

Copy link to clipboard

Copied

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.

jimmy.hunt wrote:
> 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

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 ,
Jun 18, 2006 Jun 18, 2006

Copy link to clipboard

Copied

LATEST
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.



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