Title:Using the FTP functionsContributor: Randall Goguen (aka Ranman)
Last Update: Tuesday July 18 20:19 EDT 2000
# The following code will give you a long directory listing.
<HTML><BODY><?
$fp = ftp_connect("ftp.metalab.unc.edu", 21);
ftp_login("$fp", "anonymous", "ranman@nbnet.nb.ca");
ftp_chdir("$fp", "pub/Linux");
$these_files = ftp_rawlist("$fp", ftp_pwd($fp));
$j = sizeof($these_files);
for($i=0; $i<$j; $i++) {
$this = next($these_files);
echo $this; echo "<BR>";
}
ftp_quit($fp);
?></BODY></HTML>
# FTP Function Summary.
int ftp_cdup(int stream)
Changes to the parent directory
int ftp_chdir(int stream, string directory)
Changes directories
int ftp_connect(string host [, int port])
Open a FTP stream
int ftp_delete(int stream, string path)
Deletes a file
int ftp_fget(int stream, int fp, string remote_file, int mode)
Retrieves a file from the FTP server and writes it to an open file.
int ftp_fput(int stream, string local_file, string remote_file, int mode)
Stores a file from an open file to the FTP server.
int ftp_get(int stream, string local_file, string remote_file, int mode)
Retrieves a file from the FTP server and writes it to a local file.
int ftp_login(int stream, string username, string password)
Logs into the FTP server.
int ftp_mdtm(int stream, string path)
Returns the last modification time of the file, or -1 on error
string ftp_mkdir(int stream, string directory)
Creates a directory
array ftp_nlist(int stream, string directory)
Returns an array of filenames in the given directory
int ftp_pasv(int stream, int pasv)
Turns passive mode on or off.
int ftp_put(int stream, string remote_file, string local_file, int mode)
Stores a file on the FTP server
string ftp_pwd(int stream)
Returns the present working directory.
int ftp_quit(int stream)
Closes the FTP stream
array ftp_rawlist(int stream, string directory)
Returns a detailed listing of a directory as an array of output lines
int ftp_rename(int stream, string src, string dest)
Renames the given file to a new path
int ftp_rmdir(int stream, string directory)
Removes a directory
int ftp_size(int stream, string path)
Returns the size of the file, or -1 on error.
string ftp_systype(int stream)
Returns the system type identifier
Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999 by LinuxGuruz