3 Replies Latest reply on Dec 29, 2006 7:34 AM by Newsgroup_User

    Connect to FTP Server Using CFFILE

    BrIdeas
      I am working on an internal ColdFusion solution which views and modifies folders via FTP on a web server. What I want to accomplish is on a simple form using the <input type="file" name="uploadFile" /> object. I know the way to upload files is use <cffile action="upload"> but how do you set it up to target & login to an FTP server? Or, is there an easier way that this can be accomplished?

      Thank you so much!

        • 1. Re: Connect to FTP Server Using CFFILE
          Level 7
          Use CFFTP

          http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000259.htm#1800554

          You will have to use CFFILE to upload the file first.

          --
          Ken Ford
          Adobe Community Expert
          Fordwebs, LLC
          http://www.fordwebs.com


          "BrIdeas" <webforumsuser@macromedia.com> wrote in message
          news:en1s6e$tm$1@forums.macromedia.com...
          >I am working on an internal ColdFusion solution which views and modifies
          > folders via FTP on a web server. What I want to accomplish is on a simple
          > form
          > using the <input type="file" name="uploadFile" /> object. I know the way
          > to
          > upload files is use <cffile action="upload"> but how do you set it up to
          > target
          > & login to an FTP server? Or, is there an easier way that this can be
          > accomplished?
          >
          > Thank you so much!
          >
          >
          >


          • 2. Re: Connect to FTP Server Using CFFILE
            BrIdeas Level 1
            Just to clarify then, once I do the cffile, how would my cfftp tag look?

            I know you have to do:
            <cfftp connection="myConnection" action="putFile" passive="yes">

            But how do I tell it where to find the file uploaded to the CF temp folder and then change the remote directory location?
            • 3. Re: Connect to FTP Server Using CFFILE
              Level 7
              Something like this:

              <!--- Upload the file --->
              <cffile
              action="upload"
              filefield="uploadFile"
              destination="C:\Inetpub\wwwroot\TEMP\"
              nameconflict="makeunique">

              <!--- Get the filename --->
              <cfset FileName = CFFILE.ServerFile>

              <!--- BEGIN REMOVE - DEBUGGING --->
              <cfoutput>#FileName#</cfoutput>
              <!--- END REMOVE - DEBUGGING --->

              <!--- Open an FTP Connection --->
              <cfftp
              connection = "myConnection"
              username = "FTP_UserName"
              password = "FTP_Password"
              server = "ftp.thesite.com"
              action = "open"
              stopOnError = "Yes">

              <!--- BEGIN REMOVE - DEBUGGING --->
              <p>Did Open Connection succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
              <!--- END REMOVE - DEBUGGING --->

              <!--- put the file --->
              <cfftp
              connection = "myConnection"
              action = "putFile"
              transferMode = "binary"
              localFile = "C:\Inetpub\wwwroot\TEMP\#FileName#"
              remoteFile = "C:\Temp\NEW_#FileName#">

              <!--- BEGIN REMOVE - DEBUGGING --->
              <p>Did Upload succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
              <!--- END REMOVE - DEBUGGING --->

              <!--- Close the connection --->
              <cfftp
              connection = "myConnection"
              action = "close"
              stopOnError = "Yes">

              <!--- BEGIN REMOVE - DEBUGGING --->
              <p>Did Close Connection succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
              <!--- END REMOVE - DEBUGGING --->

              <!--- Delete the local file --->
              <cffile
              action="delete"
              file="C:\Inetpub\wwwroot\TEMP\#FileName#">


              --
              Ken Ford
              Adobe Community Expert
              Fordwebs, LLC
              http://www.fordwebs.com


              "BrIdeas" <webforumsuser@macromedia.com> wrote in message
              news:en20s7$5ir$1@forums.macromedia.com...
              > Just to clarify then, once I do the cffile, how would my cfftp tag look?
              >
              > I know you have to do:
              > <cfftp connection="myConnection" action="putFile" passive="yes">
              >
              > But how do I tell it where to find the file uploaded to the CF temp folder
              > and
              > then change the remote directory location?
              >
              >