Public Method Details |
FTP
|
public void FTP( [ string $host, boolean $use_ssl, integer $port ] ) |
|
Constructor: connects to the FTP server and creates new FTP object associated with the connection.
|
Parameter |
|
string |
$host |
= >>'localhost'<< |
|
FTP server's hostname. |
|
|
boolean |
$use_ssl |
= >>false<< |
|
Wheter to use secure SSL connection. |
|
|
integer |
$port |
= >>21<< |
|
FTP service port number. |
|
Returns |
void
|
|
Login
|
public bool Login( [ string $username, string $password ] ) |
|
Logs in as a custom user.
|
Parameter |
|
string |
$username |
= >>'anonymous'<< |
|
FTP account username. |
|
|
string |
$password |
= >>'anonymous'<< |
|
FTP account password. |
|
Returns |
bool
|
|
Passive
|
public bool Passive( [ string $mode ] ) |
|
If mode is defined then turns data transfer passive mode to its value. Otherwise returns
current value of passive mode.In passive mode, data connections are initiated by the client, rather than by the server.
|
Parameter |
|
string |
$mode |
= >>null<< |
|
Whether to switch transfer mode to passive. |
|
Returns |
bool
|
|
GetOption
|
public mixed GetOption( int $option ) |
|
Returns value of specified FTP option.
|
Parameter |
|
int |
$option |
|
|
Server option. |
|
Returns |
mixed
|
|
SetOption
|
public bool SetOption( int $option, mixed $value ) |
|
Sets specified FTP option.
|
Parameter |
|
int |
$option |
|
|
Server option. |
|
|
|
Returns |
bool
|
|
Pwd
|
public string Pwd( ) |
|
Returns the current directory name, or false on error.
|
Returns |
string
|
|
Cdup
|
public bool Cdup( ) |
|
Changes to the parent directory.
|
Returns |
bool
|
|
Chdir
|
public bool Chdir( string $directory ) |
|
Changes to the specified directory.
|
Parameter |
|
string |
$directory |
|
|
Destination directory. |
|
Returns |
bool
|
|
Chmod
|
public string Chmod( int $mode, string $filename ) |
|
Sets the permissions on the remote file specified by filename to mode given as
an octal value. Returns the new file permissions on success or FALSE on error.
|
Parameter |
|
int |
$mode |
|
|
Access mode in octal format. e.g. 0644. |
|
|
string |
$filename |
|
|
Remote file name. |
|
Returns |
string
|
|
Mkdir
|
public string Mkdir( string $directory ) |
|
Creates the specified directory. Returns the newly created directory name on success, false on error.
|
Parameter |
|
string |
$directory |
|
|
Remote directory name. |
|
Returns |
string
|
|
Rmdir
|
public bool Rmdir( string $directory ) |
|
Removes the remote directory even if non-empty. In this case the directory is removed
recursively.
|
Parameter |
|
string |
$directory |
|
|
Remote directory. |
|
Returns |
bool
|
|
Directory
|
public array Directory( [ string $directory ] ) |
|
Returns an array of filenames on success, false on error.
|
Parameter |
|
string |
$directory |
= >>null<< |
|
Target directory. |
|
Returns |
array
|
|
RawList
|
public array RawList( [ string $directory ] ) |
|
Executes the FTP LIST command, and returns the result as an array.
Each array element corresponds to one line of text. The output is not parsed in any way.You can extract details for each element using ExtractInfo() method.
|
Parameter |
|
string |
$directory |
= >>null<< |
|
Remote directory name. |
|
Returns |
array
|
|
|
public array ExtractInfo( string $raw_data ) |
|
This function extracts file information from the raw result string. Associative array
containing file properties is returned. Here are property names and example values:
['raw'] : exactly matches $raw_data.
['name'] : file name, e.g. 'filename.html' or 'Some Folder'.
['mode'] : access mode in string representation, e.g. 'drw-rw-rw-' or '-rwxr-x-r-x'.
['size'] : file size in bytes, e.g. 1024.
['id'] : sorry, haven't understood yet what this identifier means.
['user'] : file owner, e.g. 'root'.
['user'] : owner's group, e.g. 'wheel'.
['date'] : last modification date, e.g. 'Sep 11 22:13'.
['mon'] : modification month, e.g. 'Feb'.
['day'] : modification day of the month, e.g. 28.
['time'] : modification time, or sometimes it contains year, e.g. '18:12' or '2004'.
|
Parameter |
|
string |
$raw_data |
|
|
A record from RawList() result array. |
|
Returns |
array
|
|
SysType
|
public string SysType( ) |
|
Returns the system type (e.g. "UNIX") of the remote FTP server.
|
Returns |
string
|
|
Get
|
public bool Get( string $local_file, string $remote_file, [ string $mode ] ) |
|
Retrieves remote_file from the FTP server, and saves it to local_file locally.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
|
Parameter |
|
string |
$local_file |
|
|
Local file name (destination). |
|
|
string |
$remote_file |
|
|
Remote file name (source). |
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
GetNb
|
public bool GetNb( string $local_file, string $remote_file, [ string $mode ] ) |
|
Retrieves remote_file from the FTP server, and saves it to local_file locally.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.The difference with Get() method is that this function retrieves the fileasynchronously, so your program can perform other operations while the file isbeing downloaded.
|
Parameter |
|
string |
$local_file |
|
|
Local file name (destination). |
|
|
string |
$remote_file |
|
|
Remote file name (source). |
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
FGet
|
public void FGet( string $filename, [ string $mode ] ) |
|
Retrieves remote_file from the FTP server, and writes it to the given file pointer, fp.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
|
string |
$mode |
= >>FTP_ASCII<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
void
|
|
FGetNb
|
public void FGetNb( string $filename, [ string $mode ] ) |
|
Retrieves remote_file from the FTP server, and writes it to the given file pointer, fp.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.The difference with FGet() method is that this function retrieves the fileasynchronously, so your program can perform other operations while the file isbeing downloaded.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
|
string |
$mode |
= >>FTP_ASCII<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
void
|
|
GetDirectory
|
public bool GetDirectory( string $local_path, string $remote_path ) |
|
Downloads full directory recursively.
|
Parameter |
|
string |
$local_path |
|
|
Destination directory (local). |
|
|
string |
$remote_path |
|
|
Source directory (remote). |
|
Returns |
bool
|
|
Alloc
|
public string Alloc( int $filesize ) |
|
Sends an ALLO command to the remote FTP server to allocate filesize bytes of space.
Returns string containing the server's responses on success, or FALSE on failure.Note: Many FTP servers do not support this command. These servers may return afailure code (FALSE) indicating the command is not supported or a success code(TRUE) to indicate that pre-allocation is not necessary and the client should continueas though the operation were successful. Because of this, it may be best to reserve thisfunction for servers which explicitly require preallocation.
|
Parameter |
|
int |
$filesize |
|
|
Size of the file for which we're allocating free space. |
|
Returns |
string
|
|
Put
|
public bool Put( string $remote_file, string $local_file, [ string $mode ] ) |
|
Stores local_file on the FTP server, as remote_file.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
|
Parameter |
|
string |
$remote_file |
|
|
Remote file name (destination). |
|
|
string |
$local_file |
|
|
Local file name (source). |
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
PutNb
|
public bool PutNb( string $remote_file, string $local_file, [ string $mode ] ) |
|
Stores local_file on the FTP server, as remote_file.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.The difference between this method and the Put() is that this function uploads the fileasynchronously, so your program can perform other operations while the file is being uploaded.
|
Parameter |
|
string |
$remote_file |
|
|
Remote file name (destination). |
|
|
string |
$local_file |
|
|
Local file name (source). |
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
FPut
|
public bool FPut( string $remote_file, int $fp, [ string $mode ] ) |
|
Uploads the data from the file pointer fp until end of file. The results are stored in remote_file on the FTP server.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
|
Parameter |
|
string |
$remote_file |
|
|
Remote file name (destination). |
|
|
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
FPutNb
|
public bool FPutNb( string $remote_file, int $fp, [ string $mode ] ) |
|
Uploads the data from the file pointer fp until end of file. The results are stored in remote_file on the FTP server.
The transfer mode specified must be either FTP_ASCII or FTP_BINARY.The difference between this method and the Put() is that this function uploads the fileasynchronously, so your program can perform other operations while the file is being uploaded.
|
Parameter |
|
string |
$remote_file |
|
|
Remote file name (destination). |
|
|
|
|
string |
$mode |
= >>FTP_BINARY<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|
PutDirectory
|
public bool PutDirectory( string $remote_path, string $local_path ) |
|
Uploads full directory recursively.
|
Parameter |
|
string |
$remote_path |
|
|
Destination directory (local). |
|
|
string |
$local_path |
|
|
Source directory (remote). |
|
Returns |
bool
|
|
NbContinue
|
public int NbContinue( ) |
|
Continues retrieving/sending a file non-blocking.
Returns FTP_FAILED or FTP_FINISHED or FTP_MOREDATA.See the PHP Manual/function.ftp-nb-continue.html for more details.
|
Returns |
int
|
|
Size
|
public int Size( string $filename ) |
|
Returns the size of a file. If an error occurs, of if the file does not exist, -1
is returned. Not all servers support this feature.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
Returns |
int
|
|
Modified
|
public int Modified( string $filename ) |
|
Checks the last-modified time for a file, and returns it as a UNIX timestamp.
If an error occurs, or the file does not exist, -1 is returned.Note that not all servers support this feature.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
Returns |
int
|
|
Rename
|
public bool Rename( string $source, string $destination ) |
|
Renames (moves) the file on the FTP server.
|
Parameter |
|
string |
$source |
|
|
Original file name. |
|
|
string |
$destination |
|
|
New file name. |
|
Returns |
bool
|
|
Delete
|
public bool Delete( string $path ) |
|
Deletes the file specified by path from the FTP server.
|
Parameter |
|
string |
$path |
|
|
Path of the file to delete. |
|
Returns |
bool
|
|
Raw
|
public array Raw( string $cmd ) |
|
Sends an arbitrary command to the FTP server. Returns the server's response as an array
of strings. No parsing is performed on the response string, nor does ftp_raw() determineif the command succeeded.
|
Parameter |
|
|
Returns |
array
|
|
Exec
|
public bool Exec( string $cmd ) |
|
Request execution of program on FTP server. This may be forbidden for your account.
|
Parameter |
|
string |
$cmd |
|
|
Command for execution (program or shell cmd). |
|
Returns |
bool
|
|
Site
|
public bool Site( string $cmd ) |
|
Sends the command specified by cmd to the FTP server.
SITE commands are not standardized, and vary from server to server.They are useful for handling such things as file permissions and group membership.
|
Parameter |
|
string |
$cmd |
|
|
FTP server command. Example: "chmod 777 filename.ext". |
|
Returns |
bool
|
|
Close
|
public void Close( ) |
|
Closes connection with the FTP server.
|
Returns |
void
|
|
FOpenRead
|
public void FOpenRead( string $filename, [ string $mode ] ) |
|
Opens remote file for reading and returns the file handler.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
|
string |
$mode |
= >>FTP_ASCII<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
void
|
|
FCloseRead
|
public bool FCloseRead( int $fp ) |
|
Closes remote file open for reading by FTP::FOpenRead() method.
|
Parameter |
|
|
Returns |
bool
|
|
FOpenWrite
|
public void FOpenWrite( string $filename, [ string $mode ] ) |
|
Opens the remote file for writing and returns the file handler.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
|
string |
$mode |
= >>FTP_ASCII<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
void
|
|
FCloseWrite
|
public bool FCloseWrite( string $filename, int $fp, [ string $mode ] ) |
|
Closes remote file open for writing by FTP::FOpenWrite() method and saves the changes.
|
Parameter |
|
string |
$filename |
|
|
Remote file name. |
|
|
|
|
string |
$mode |
= >>FTP_ASCII<< |
|
Transfer mode: FTP_ASCII for text files or FTP_BINARY for others. |
|
Returns |
bool
|
|