//close connection
ftp_quit($ftp);
?>
boolean ftp_delete(integer link, string path)
The ftp_delete function removes a file on the remote server. The link argument is as
returned by ftp_connect. The path argument is the path on the remote server to the file
to be deleted. See ftp_put for an example of use.
boolean ftp_fget(integer link, integer file, string filename,
integer mode)
The ftp_fget function copies a remote file into an open file stream. You must create a
file resource using fopen or a similar function to pass as the second argument. The mode
argument should be set with one of two constants: FTP_ASCII or FTP_IMAGE. These are
sometimes referred to as text or binary modes.
<?
//connect to server
if(!($ftp = ftp_connect("localhost")))
{
print("Unable to connect!BR>\n");
exit();
}
//log in
if(!ftp_login($ftp, "anonymous", "corephp@localhost"))
{
print("Unable to login!BR>\n");
exit();
}
//open local file for writing
$fp = fopen("/tmp/ftp_fget.test", "w");
//save remote file in open file stream
if(!ftp_fget($ftp, $fp, "data.txt", FTP_ASCII)))
{
print("Unable to get remote file!BR>\n");
}
//close local file
fclose($fp);
//close connection
ftp_quit($ftp);
?>