Jump to content


Photo

FTP Download


  • Please log in to reply
5 replies to this topic

#1 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 14 August 2006 - 07:08 PM

I am interested in downloading a file from a ftp server using php here is what I have:



function FTP_File ($dir,$file){ 
  $remote_dir=$dir."/".$file;
  $local_dir="c:\\".$file;
  $handle=fopen($local_dir, 'w');
  echo "Getting file: $remote_dir, and putting it $local_dir<br>";  // For testing purpose
  if(ftp_fget($_SESSION['FTP'],$handle,$remote_dir, FTP_BINARY)){echo "SUCCESS!";}
  else {echo "Didnt Work!";}	
}

Output:

Getting file: /public_ftp/POS/Restaraunt Manager/Common/Security Key.txt, and putting it c:\Security Key.txt
SUCCESS!


I get no errors, but the file isnt there.  I tried several files but nothing seems to work.  Any suggestions?

#2 yassen

yassen
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 August 2006 - 07:34 PM

To say the obvious, you do not close the local file you are writing to. Try adding

fclose($handle);

somewhere after the ftp session has ended and try again.

#3 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 14 August 2006 - 07:47 PM

Nah, doesnt help.  Thanks though.

#4 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 15 August 2006 - 01:19 PM

No one has a clue?

#5 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 15 August 2006 - 03:02 PM

No one has experience in PHP FTP?  I would have thought this was a very simple operation and have gotten an answer very quickly!  Someone out there has got to know what I am doing wrong.

#6 akrytus

akrytus
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 15 August 2006 - 05:12 PM

Ok here is what I have found out.

The server is saving the file on the server side in its current public_html dir as c:\$filename.  How can I save this FTP file on a local drive instead?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users