4 Replies Latest reply on Jun 18, 2006 12:15 AM by BKBK

    cffile upload - cut and paste

    jimmy.hunt
      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
        • 1. Re: cffile upload - cut and paste
          Level 7
          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
          >
          • 2. Re: cffile upload - cut and paste
            jimmy.hunt Level 1
            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
            • 3. Re: cffile upload - cut and paste
              Level 7
              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
              • 4. Re: cffile upload - cut and paste
                BKBK Adobe Community Professional & MVP
                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.