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

Using CFFTP

Explorer ,
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

I need to pull multiple files of various type from an ftp server. All files are pulled from the same folder.

These are files supplied by a content provider and I basically need to pull all these files down once a week to a local directory.

I figured out how to grab one file at a time and store it in the appropriate folder, but I want to just be able to pull all the files from the folder regardless of name and regardless of how many files there are.

Any advice would be appreciated.

Thanks.

Scott
TOPICS
Advanced techniques

Views

467

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
Guest
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

You should be able to loop though and just use the getFile to copy all the files you need.

An example:

<CFSET newFeedDir = GetDirectoryFromPath(GetTemplatePath()) & "test\">

<cfftp action="listdir"
username="****"
password="****"
name="feedDir"
server="test.com"
transferMode="binary"
failIfExists="No" directory="/">

<CFFTP CONNECTION="myConnection"
USERNAME="*****"
PASSWORD="*****"
SERVER="test.com"
ACTION="Open">

<CFLOOP query="feedDir">
<CFFTP connection="myConnection"
ACTION="GetFile"
NAME="qryFTP"
TRANSFERMODE="Binary"
FAILIFEXISTS="No"
LOCALFILE="#newFeedDir##Name#"
REMOTEFILE="/#Name#">
</CFLOOP>

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
Contributor ,
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

You could use CFDIRECTORY to get a list of all the files in the directory, loop through the list and download the file.

See
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=C...

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 ,
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

James74, cfdirectory is for local file transfer, whereas Scott wishes to get the file from a remote FTP server. It's a natural oversight that happens to all of us.

Amers, your code is the kind I would use. Shouldn't the second cfftp tag, with action="open", come first? Also, should there be a forward slash in the value of the RemoteFile attribute? I would suggest ending the code with the cfftp tag,

<cfftp action="close" connection="myConnection">



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
Guest
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

BKBK, you're right.. you do want to close the connection after you're finished. Also, basically under remotefile - you should put whatever the directory structure is on the other side. In this case, I used "/" - because I had actually used this in a script I wrote.

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 ,
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

Thanks a bunch all!

I got everything working perfectly thanks to your advice!

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
Guest
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

LATEST
BKBK's right about CFDIRECTORY. But you could use <CFFTP ACTION="listdir" ...> on the remote server to achieve the same results.

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