Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

<?
//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();
}


//save file to tmp directory
ftp_get($ftp, "/tmp/data.bin", "/pub/data.bin",FTP_IMAGE);


//close connection
ftp_quit($ftp);
?>


boolean ftp_login(integer link, string username, string
password)


Once you make a connection to an FTP server, you must use ftp_login to identify
yourself. All three arguments are required, even if you are logging in anonymously. See
ftp_connect for an example of use.


integer ftp_mdtm(integer link, string path)


The ftp_mdtm function returns the last modification time for the file named in the path
argument.


<?
//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();
}


//get the size of the README file

Free download pdf