FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
ftp_alloc()
[ftp_alloc – Allocates space for a file to be uploaded] |
This function allocates space for a file to be uploaded by sending an ALLO command to the remote FTP server. Owing to the fact that many servers do not support this command, it is best to reserve this function for servers that explicitly require preallocation. |
ftp_alloc(ftp_stream, filesize, &result [optional parameter – if a variable is provided, a textual representation of the server’s response will be returned by reference]); |
ftp_alloc() : returns TRUE on success; FALSE on failure. |
ftp_append()
[ftp_append – Append content of a file to another file on the FTP server] |
This function appends the content of a file to another file on the FTP server. |
ftp_append(ftp_resource, remote_file, local_file, mode [optional parameter, with a default value of FTP_IMAGE]); |
ftp_append() : returns TRUE on success, FALSE on failure. |
ftp_cdup()
[ftp_cdup – Changes to the parent directory] |
This function navigates one level up the FTP directory structure; thus, it changes to the parent directory. |
ftp_cdup(ftp_stream);
[The ftp_stream parameter represents the link identifier of the FTP connection.] |
ftp_cdup() : returns TRUE on success, or FALSE on failure. |
ftp_chdir()
[ftp_chdir – Changes the current directory on a FTP server] |
This function changes the current directory on a FTP server to the one specified by directory. |
ftp_chdir(ftp_stream, directory); |
ftp_chdir() : returns TRUE on success; FALSE and a warning on failure. |
ftp_chmod()
[ftp_chmod – Set permissions on a file via FTP] |
This function sets permissions on [‘changes the mode of] remote_file to mode via FTP. |
ftp_chmod(ftp_stream, mode, filename);
[mode specifies the new permissions, given as an octal value]. |
ftp_chmod() : returns the new file permissions as an integer on success; FALSE on error. |
ftp_close()
[ftp_close – Closes an FTP connection] |
This function – an alias of ftp_quit() – closes ftp_stream and releases the resource. |
ftp_close(ftp_stream);
[Once this function has been called, the FTP connection can no longer be used; a new FTP connection must be created using ftp_connect() .] |
ftp_close() : returns TRUE on success; FALSE on failure. |
ftp_connect()
[ftp_connect – Opens an FTP connection] |
This function opens an FTP connection to host. |
ftp_connect(host, port [optional parameter], timeout [optional parameter]);
[port specifies an alternate port to connect to, with a default FTP port value of 21. timeout specifies the timeout in seconds for all subsequent network operations; the default value is 90. This value can be changed (ftp_set_option() ) and queried (ftp_get_option() ) at any time.] |
ftp_connect() : returns an FTP stream on success; FALSE on error. |
ftp_delete()
[ftp_delete – Deletes a file on the FTP server] |
This function deletes the file specified by path from the FTP server. |
ftp_delete(ftp_stream, path); |
ftp_delete() : returns TRUE on success; FALSE on failure. |
ftp_exec()
[ftp_exec – Requests execution of a command on the FTP server] |
This function sends a SITE EXEC command request to the FTP server. |
ftp_exec(ftp_stream, command); |
ftp_exec() : returns TRUE if the command was successful [server responded with HTTP code 200]; FALSE otherwise. |
ftp_fget()
[ftp_fget – Downloads a file from the FTP server and saves to an open file] |
This function downloads [‘gets’] remote_file from the FTP server and writes it to the given file_pointer. |
ftp_fget(ftp_stream, file_pointer, remote_file, mode [optional parameter, with a default value of FTP_IMAGE], resume_pos [optional parameter, with a default value of 0]);
[mode specifies the mode of transport – must be either FTP_ASCII or FTP_BINARY. resume_pos specifies the position in remote_file to start downloading from.] |
ftp_fget() : returns TRUE on success; FALSE on failure. |
ftp_fput()
[ftp_fput – Uploads from an open file to the FTP server] |
This function uploads [‘puts’] the data from file_pointer to remote_file on the FTP server. |
ftp_fput(ftp_stream, remote_file, file_pointer, mode [optional parameter, with a default value of FTP_IMAGE], startpos [optional parameter, with a default value of 0]);
[mode specifies the transfer mode, and must be either FTP_ASCII or FTP_BINARY. startpos specifies the position in remote_file to start uploading to.] |
ftp_fput() : returns TRUE on success; FALSE on failure. |
ftp_get_option()
[ftp_get_option – Retrieves various runtime behaviours of the current FTP stream] |
This function returns [‘gets’] the value for the requested option from the specified FTP connection. |
ftp_get_option(ftp_stream, option);
[option can be either FTP_TIMEOUT_SEC (returns the current timeout used for network-related operations) or FTP_AUTOSEEK (returns TRUE if this option is on; FALSE otherwise).] |
ftp_get_option() : returns the value on success; FALSE and a warning if option is not supported. |
ftp_get()
[ftp_get – Downloads a file from the FTP server] |
This function retrieves [‘gets’] remote_file from the FTP server, and saves it into local_file. |
ftp_get(ftp_stream, local_file, remote_file, mode [optional parameter, with a default value of FTP_BINARY], resumepos [optional parameter, with a default value of 0]);
[The file specified by local_file will be overwritten if it already exists. The transfer mode must be either FTP_ASCII or FTP_BINARY. resumepos specifies the position in remote_file to start downloading from.] |
ftp_get() : returns TRUE on success; FALSE on failure. |
ftp_login()
[ftp_login – Logs in to an FTP connection] |
This function logs in to ftp_stream. |
ftp_login(ftp_stream, username, password); |
ftp_login() : returns TRUE on success; FALSE and a warning on failure. |
ftp_mdtm()
[ftp_mdtm – Returns the last modified time of the given file] |
This function gets the last modified time of remote_file, located on an FTP server. Not all servers support this feature, and this function does not work with directories. |
ftp_mdtm(ftp_stream, remote_file); |
ftp_mdtm() : returns the last modified time as a Unix timestamp on success; -1 on failure. |
ftp_mkdir()
[ftp_mkdir – Creates a directory] |
This function creates [‘makes’] the specified directory on the FTP server. |
ftp_mkdir(ftp_stream, directory); |
ftp_mkdir() : returns the newly-created directory name as a string on success; FALSE on error. |
ftp_mlsd()
[ftp_mlsd – Returns a list of files in the given directory] |
This function returns a manifest list of the files stored in directory on the FTP server. |
ftp_mlsd(ftp_stream, directory); |
ftp_mlsd() : returns an array of arrays with file information from directory on success; FALSE on error. |
ftp_nb_continue()
[ftp_nb_continue – Continues retrieving/sending a file (non-blocking)] |
This function facilitates the continued retrieval/sending of a file from/to an FTP server in a non-blocking fashion. |
ftp_nb_continue(ftp_stream); |
ftp_nb_continue() : returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA. |
ftp_nb_fget()
[ftp_nb_fget – Retrieves a file from the FTP server and writes it to an open file (non-blocking)] |
This function retrieves [‘gets’] remote_file from the FTP server in an asynchronous [‘non-blocking’] manner. |
ftp_nb_fget(ftp_stream, file_pointer, remote_file, mode [optional parameter with a default value of FTP_IMAGE], resumepos [optional parameter, with a default value of 0]);
[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. resumepos represents the position in remote_file to start downloading from.] |
ftp_nb_fget() : returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA. |
ftp_nb_fput()
[ftp_nb_fput – Uploads the data from an open file to the FTP server (non-blocking)] |
This function uploads [‘puts’] data from the open file_pointer to remote_file on the FTP server, in an asynchronous [‘non-blocking’] manner. |
ftp_nb_fput(ftp_stream, remote_file, file_pointer, mode [optional parameter, with a default value of FTP_IMAGE], startpos [optional parameter, with a default value of 0]);
[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.] |
ftp_nb_fput() : returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA. |
ftp_nb_get()
[ftp_nb_get – Retrieves a file from the FTP server and writes it to a local file (non-blocking)] |
This function retrieves [‘gets’] remote_file from the FTP server and saves it into local_file, in an asynchronous [‘non-blocking’] manner. |
ftp_nb_get(ftp_stream, local_file, remote_file, mode [optional parameter with a default value of FTP_IMAGE], resumepos [optional parameter, with a default value of 0]);
[mode represents the transfer mode, and must be either FTP_ASCII or FTP_BINARY. resumepos specifies the position in remote_file to start downloading from.] |
ftp_nb_get() : returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA. |
ftp_nb_put()
[ftp_nb_put – Stores a file on the FTP server (non-blocking)] |
This function uploads [‘puts’] local_file to the FTP server, in an asynchronous [‘non-blocking’] manner. |
ftp_nb_put(ftp_stream, remote_file, local_file, mode [optional parameter, with a default value of FTP_IMAGE], startpos [optional parameter, with a default value of 0]);
[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.] |
ftp_nb_put() : returns one of three values – FTP_FAILED; FTP_FINISHED; or FTP_MOREDATA. |
ftp_nlist()
[ftp_nlist – Returns a list of files in the given directory] |
This function returns an array [a ‘numbered list’] of files in the given directory on the FTP server. |
ftp_nlist(ftp_stream, directory);
[directory represents the directory to be listed. This parameter can also include arguments, but is not escaped – so there may be some issues with filenames containing spaces and other characters.] |
ftp_nlist() : returns an array of filenames from directory on success; FALSE on error. |
ftp_pasv()
[ftp_pasv – Turns passive mode on or off] |
In passive mode data connections are initiated by the client rather than the FTP server — this may be needed if the client is behind a firewall. This function turns passive mode on or off, and can only be called after a successful login – otherwise it will fail. |
ftp_pasv(ftp_stream, pasv);
[If pasv is TRUE then passive mode is turned on; otherwise it is turned off.]. |
ftp_pasv() : returns TRUE on success; FALSE on failure. |
ftp_put()
[ftp_put – Uploads a file to the FTP server] |
This function uploads [‘puts’] local_file into remote_file on the FTP server. |
ftp_put(ftp_stream, remote_file, local_file, mode [optional parameter with a default value of FTP_IMAGE], startpos [optional parameter with a default value of 0]);
[mode specifies the transfer mode and must be either FTP_ASCII or FTP_BINARY. startpos represents the position in remote_file to start uploading to.] |
ftp_put() : returns TRUE on success; FALSE on failure. |
ftp_pwd()
[ftp_pwd – Returns the current directory name] |
This function returns the name of the present working directory of the FTP server. |
ftp_pwd(ftp_stream);
|
ftp_pwd() : returns the current [‘present’] working directory name on success; FALSE on error. |
ftp_raw()
[ftp_raw – Sends an arbitrary command to an FTP server] |
This function sends an unrefined [‘raw’] FTP command to the FTP server. |
ftp_raw(ftp_stream, command); |
ftp_raw() : returns the server’s response as an array of strings. No parsing is performed on the response string, and the success or otherwise of the command is not determined. |
ftp_rawlist()
[ftp_rawlist – Returns a detailed list of files in the given directory] |
This function executes the FTP LIST command, and returns the result as an array. |
ftp_rawlist(ftp_stream, directory, recursive [optional parameter, with a default value of FALSE]);
[directory specifies the directory path, and may include arguments for the LIST command. If recursive is set to TRUE, the issued command will be LIST -R .] |
ftp_rawlist() : returns an array where each element corresponds to one line of text on success; FALSE if directory is invalid. The output is not parsed; the system type identifier returned by ftp_systype() can be used to determine how the results should be interpreted. |
ftp_rename()
[ftp_rename – Renames a file or a directory on the FTP server] |
This function renames a file or a directory on the FTP server. |
ftp_rename(ftp_stream, oldname, newname); |
ftp_rename() : returns TRUE on success; FALSE and an E_WARNING-level error on failure. |
ftp_rmdir()
[ftp_rmdir – Removes a directory] |
This function removes the specified directory from the FTP server. |
ftp_rmdir(ftp_stream, directory);
[directory must be a relative or absolute path to an empty directory.] |
ftp_rmdir() : returns TRUE on success; FALSE on failure. |
ftp_set_option()
[ftp_set_option – Set miscellaneous runtime FTP options] |
This function controls [‘sets’] various runtime options for the specified ftp_stream. |
ftp_set_option(ftp_stream, option, value);
[option can take the form of FTP_TIMEOUT_SEC [default value of 90 seconds], FTP_AUTOSEEK [enabled by default], or FTP_USEPASVADDRESS.] |
ftp_set_option() : returns TRUE if the option could be set; FALSE if not. A warning will be thrown if option is not supported, or the passed value doesn’t match the expected value for the given option. |
ftp_site()
[ftp_site – Sends a SITE command to the server] |
This function sends the given SITE command to the FTP server. SITE commands vary from server to server and are useful for dealing with concepts like file permissions and group membership; these commands are not standardized. |
ftp_site(ftp_stream, command);
[command represents the SITE command. There may be some issues with filenames containing spaces and other characters since this parameter is not escaped.] |
ftp_site() : returns TRUE on success; FALSE on failure. |
ftp_size()
[ftp_size – Returns the size of the given file] |
This function returns the size of remote_file on the FTP server in bytes. This feature is not supported by all servers. |
ftp_size(ftp_stream, remote_file); |
ftp_size() : returns the file size on success; -1 on error. |
ftp_ssl_connect()
[ftp_ssl_connect – Opens a Secure SSL-FTP connection] |
This function will succeed even if the server is not set up for SSL-FTP – or its certificate is invalid – since it opens an explicit SSL-FTP connection to the specified host. In these instances, the client will send the appropriate AUTH FTP command when ftp_login() is called — resulting in a ftp_login() failure. To make this function available (rather than ‘undefined’) on Windows you must compile your own PHP binaries, since both the ftp module and the OpenSSL support are required to be built statically into PHP. |
ftp_ssl_connect(host, port [optional parameter, with a default value of 21], timeout [optional parameter, with a default value of 90 (seconds)]);
[host should have no trailing slashes and should not be prefixed with ftp:// .] |
ftp_ssl_connect() : returns a SSL-FTP stream on success; FALSE on error. |
ftp_systype()
[ftp_systype – Returns the system type identifier of the remote FTP server] |
This function returns the system type identifier of the remote ftp server. |
ftp_systype(ftp_stream); |
ftp_systype() : returns the remote system type on success; FALSE on error. |