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

Connect to FTP Server Using CFFILE

New Here ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

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!

TOPICS
Advanced techniques

Views

1.1K

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 ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

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!
>
>
>


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
New Here ,
Dec 28, 2006 Dec 28, 2006

Copy link to clipboard

Copied

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?

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 ,
Dec 29, 2006 Dec 29, 2006

Copy link to clipboard

Copied

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


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