Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

Download a file from FTP with CFFTP tag

I'm trying to download files from a ftp server using CFFTP tag from my website.
The code is:

<cfftp action="GETFILE" server="xxxx" username="xxxx"
password="xxxxx" stoponerror="Yes" passive="Yes"
localfile="c:\test.nfo" remotefile="/test/test.nfo" transfermode="AUTO" failifexists="No" asciiextensionlist="nfo;sfv;" passivemode="yes">

<CFOUTPUT>
FTP directory listing of #cfftp.returnvalue#.
</CFOUTPUT>

but not works cause anything is downloaded. The result is:
FTP directory listing of 226 Transfer complete..

but anything downloaded

What are am I doing wrong?
Help

0
Xavi053000
Asked:
Xavi053000
1 Solution
 
meverestCommented:
this is similar to doing this:
========================================
C:> cd c:\temp
C:\temp> ftp xxx
User (xxx): xxx
password: xxx
ftp:> cd /test
ftp:> get test.nfo
ftp:> bye
========================================

so you would expect that the file 'test.nfo' will be copied to your local directory c:\temp\test.nfo

now you can use ccfile to open that file and process it however you want, like:

<cffile action="READ" file="c:\temp\test.nfo" variable="var">

<cfoutput>
contents of file: #var#
</cfoutput>

0
 
Xavi053000Author Commented:
Ok, for text files this work but if i would like that the user download a mp3, exe, jpg file from the ftp through the navigator? readbinary don't works. :(
0
 
meverestCommented:
if you want to display the downloaded images in the browser, just do a cfftp to save the file into a web folder (eg: localfile="c:\inetpub\wwwroot\test.gif") then just display it like usual: <img src="test.gif">

you could use cfcontent, but the above is the easiest way.

cheers.
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
Xavi053000Author Commented:
No, i want that the user download the file as when he download a file with <a href="test.exe">, but the ftp with cfftp. D u understand me?
0
 
meverestCommented:
well, cfftp is for downloading files from an ftp server to the coldfusion server, so you can't use it to transfer files to the end user.

if you want to send a file to the end user, you need to use some other method, like cfcontent maybe.

0
 
Xavi053000Author Commented:
well, thx for the help, but i don't know how make it with cfcontent, don't works fine
0
 
meverestCommented:
hi,

try this:

<CFHEADER NAME="Content-Disposition" VALUE="filename=filename.ext">
<cfcontent type="application/octet-stream" file="driveletter:\path\filename.ext">

change the relevent values to suit, but that will cause the 'save as' box to pop up on the user's browser to start the download.

cheers.
0
 
Xavi053000Author Commented:
0
 
Xavi053000Author Commented:
Sorry, my last message is wrong. The result of thjis cfcontent is the anssi characters of the mp3 file to download. I want that the navigator let me download the file where i want as u make Save As...
0
 
mrichmonCommented:
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation in the Cleanup topic area:

Accept meverest

Please leave any comments here within the next four days.

mrichmon
EE Cleanup Volunteer
0
 
GhostModCommented:
PAQed, with points refunded (50)

GhostMod
Community Support Moderator
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now