note 41289 added to function.ftp-fget
| From: | bkreleger at rn2 dot php dot net | Date: | Mon, 05 Apr 2004 19:21:38 +0000 |
| Subject: | note 41289 added to function.ftp-fget | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67670@lists.php.net to get a copy of this message | ||
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);
?>
----
Manual Page -- http://www.php.net/manual/en/function.ftp-fget.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41289
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41289&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41289&report=yes
Search -- http://master.php.net/manage/user-notes.php