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

(singke) #1

array ftp_nlist(integer link, string directory)


The ftp_nlist function returns an array of files in the specified directory.


boolean ftp_pasv(integer link, boolean on)


Use ftp_pasv to turn passive mode on or off. It is off by default.


boolean ftp_put(integer link, string remote, string local,
integer mode)


The ftp_put function copies a file from the local filesystem to the remote server. The
link argument is as returned by ftp_connect. The local and remote arguments specify
paths. The mode argument should be either FTP_ASCII or FTP_IMAGE.


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


//copy local file to remote server
ftp_put($ftp, "/uploads/data.txt", "
/tmp/data.txt", FTP_ASCII);


//remove remote file
ftp_delete($ftp, "/uploads/data.txt");


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


string ftp_pwd(integer link)


The ftp_pwd function returns the name of the current directory. See ftp_connect for an
example of use.

Free download pdf