note 41289 deleted from function.ftp-fget by didou

From: Date: Sun, 16 Jan 2005 05:25:00 +0000
Subject: note 41289 deleted from function.ftp-fget by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83367@lists.php.net to get a copy of this message
Note Submitter: bkreleger (at) phphulp (dot) nl ---- Note that the example above is confusing you if you've never tried this function before. The example uses '$file' for defining the filename to open. When requestion the ftp_fget function, also '$file' is being used. Note that the second '$file' must be the filename on the FTP, not the local file to store the downloaded data in. The example asumed that the filename on the local machine is the same as the filename on the FTP address. So the example above, when ajusted, should be like this: <?php // define file on FTP $ftp_file = "someotherfile.txt"; // open some file for reading $file = 'somefile.txt'; $fp = fopen($file, 'w'); // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to download $file if (ftp_fget($conn_id, $fp, $ftp_file, FTP_ASCII, 1)) { echo "successfully written to $file\n"; } else { echo "There was a problem with $file\n"; } // close the connection and the file handler ftp_close($conn_id); fclose($fp); ?>

« previous php.notes (#83367) next »