Link to home
Start Free TrialLog in
Avatar of Xavi053000
Xavi053000

asked on

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

Avatar of meverest
meverest
Flag of Australia image

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>

Avatar of Xavi053000
Xavi053000

ASKER

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. :(
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.
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?
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.

well, thx for the help, but i don't know how make it with cfcontent, don't works fine
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.
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...
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
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial