PHP FTP 函數使用教程
引進的PHP的FTP
該功能提供的FTP客戶端訪問文件服務器通過文件傳輸協議( FTP ) 。
該FTP函數是用來打開,登錄名和密切的聯系,以及上傳,下載,重命名,刪除和獲取信息的文件從文件服務器。並不是所有的FTP功能將與每一個服務器或返回同樣的結果。該FTP函數成為可與PHP 3 。
這些功能都是為了詳細訪問FTP服務器。如果你只希望閱讀或寫入文件在FTP服務器上,可以考慮使用包裝的ftp://與文件的功能。
安裝
PHP的Windows版本內置了支持的FTP延長。因此, FTP函數將自動工作。
然而,如果您運行的是Linux版本的PHP中,你將不得不與編譯PHP -啟用-的F TP( P HP4中+ )或- wi th-的F T P(P H P3中)得到的F T P職能工作。
PHP的FTP函數
PHP的:顯示最早的PHP版本,支持的功能。
Function |
Description |
PHP |
ftp_alloc()
Allocates space for a file to be uploaded to the FTP server
5
ftp_cdup()
Changes the current directory to the parent directory on the FTP server
3
ftp_chdir()
Changes the current directory on the FTP server
3
ftp_chmod()
Sets permissions on a file via FTP
5
ftp_close()
Closes an FTP connection
4
ftp_connect()
Opens an FTP connection
3
ftp_delete()
Deletes a file on the FTP server
3
ftp_exec()
Executes a program/command on the FTP server
4
ftp_fget()
Downloads a file from the FTP server and saves it to an open file
3
ftp_fput()
Uploads from an open file and saves it to a file on the FTP server
3
ftp_get_option()
Returns runtime behaviors of the FTP connection
4
ftp_get()
Downloads a file from the FTP server
3
ftp_login()
Logs on to an FTP connection
3
ftp_mdtm()
Returns the last modified time of a specified file
3
ftp_mkdir()
Creates a new directory on the FTP server
3
ftp_nb_continue()
Continues retrieving/sending a file (non-blocking)
4
ftp_nb_fget()
Downloads a file from the FTP server and saves it to an open file (non-blocking)
4
ftp_nb_fput()
Uploads from an open file and saves it to a file on the FTP server (non-blocking)
4
ftp_nb_get()
Downloads a file from the FTP server (non-blocking)
4
ftp_nb_put()
Uploads a file to the FTP server (non-blocking)
4
ftp_nlist()
Lists the files in a specified directory on the FTP server
3
ftp_pasv()
Turns passive mode on or off
3
ftp_put()
Uploads a file to the FTP server
3
ftp_pwd()
Returns the current directory name
3
ftp_quit()
Alias of ftp_close()
3
ftp_raw()
Sends a raw command to the FTP server
5
ftp_rawlist()
Returns a detailed list of files in the specified directory
3
ftp_rename()
Renames a file or directory on the FTP server
3
ftp_rmdir()
Removes a directory on the FTP server
3
ftp_set_option()
Sets runtime options for the FTP connection
4
ftp_site()
Sends a SITE command to the server
3
ftp_size()
Returns the size of the specified file
3
ftp_ssl_connect()
Opens a secure SSL-FTP connection
4
ftp_systype()
Returns the system type identifier of the FTP server
3
PHP FTP Constants
PHP: indicates the earliest version of PHP that supports the constant.
Constant |
Description |
PHP |
FTP_ASCII
3
FTP_TEXT
3
FTP_BINARY
3
FTP_IMAGE
3
FTP_TIMEOUT_SEC
3
FTP_AUTOSEEK
4
FTP_AUTORESUME
Determine resume position and start position for get and put requests automatically
4
FTP_FAILED
Asynchronous transfer has failed
4
FTP_FINISHED
Asynchronous transfer has finished
4
FTP_MOREDATA
Asynchronous transfer is still active
4