FTP operation functions in php (function description)

Source: Internet
Author: User
Tags remote ftp server
FTP operation functions in php (function description)
This article introduces the usage of ftp operation functions in php and describes the main function functions. For more information, see.

The ftp operation functions in php mainly include:

Ftp_connect: Open the FTP Link. Ftp_login: log on to the FTP server. Ftp_pwd: obtain the current path. Ftp_cdup: return to the upper directory. Ftp_chdir: change the path. Ftp_mkdir: create a directory. Ftp_rmdir: delete the directory. Ftp_nlist: list all files in the specified directory. Ftp_rawlist: lists all objects in a specified directory in detail. Ftp_0000ype: displays the server system. Ftp_pasv: switch the active/passive transmission mode. Ftp_get: download an object. Ftp_fget: download the file, which exists in the opened file. Ftp_put: upload a file. Ftp_fput: upload an opened file. Ftp_size: get the size of the specified file. Ftp_mdtm: get the last modification time of the specified file. Ftp_rename: rename the file. Ftp_delete: delete the file. Ftp_quit: disable the FTP connection.

The following describes ftp operation functions in php.

Ftp_connectOpen the FTP Link. Syntax: int ftp_connect (string host, int [port]); return value: integer function type: network system Content Description: This function can open the FTP server link. The host parameter is the URL of the FTP server. The port parameter is usually omitted. if the port number of the FTP server is not 21, this parameter must be added. If no error exists, the connection code is returned. if the connection fails, the false value is returned. Reference: ftp_quit ()

Ftp_loginLog on to the FTP server. Syntax: boolean ftp_login (int ftp_stream, string username, string password); return value: boolean function type: network system capacity Description: This function can be used to log on to the linked FTP server. The ftp_stream parameter is the FTP connection code. The username and password parameters are respectively the user account and password of the server. generally, anonymous is a public account, and the password is Email. If the call succeeds, the return value is true.

Ftp_pwdObtain the current path. Syntax: string ftp_pwd (int ftp_stream); return value: string function type: Network System Description: This function is used to obtain the path currently on the FTP server. The ftp_stream parameter is the FTP connection code. If any error occurs, NULL is returned.

Ftp_cdupGo back to the upper directory. Syntax: boolean ftp_cdup (int ftp_stream); return value: boolean function type: network system Content Description: This function is used to return to the upper Directory, that is, the parent directory of the current directory. The ftp_stream parameter is the FTP connection code. If the call succeeds, the return value is true.

Ftp_chdirChange the path. Syntax: boolean ftp_chdir (int ftp_stream, string directory); return value: boolean function type: Network System Description: This function is used to change the path. The ftp_stream parameter is the FTP connection code. The directory parameter is the directory to go. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_mkdirCreate a directory. Syntax: string ftp_mkdir (int ftp_stream, string directory); return value: string function type: network system Content Description: This function is used to create a new directory. The ftp_stream parameter is the FTP connection code. The directory parameter is the new directory to be created. If the operation succeeds, the created directory name is returned. if the operation fails, the system returns false.

Ftp_rmdirDelete a directory. Syntax: boolean ftp_chdir (int ftp_stream, string directory); return value: boolean function type: Network System Description: This function is used to delete an empty directory. The ftp_stream parameter is the FTP connection code. The directory parameter is the directory to be deleted. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_nlistLists all objects in a specified directory. Syntax: array ftp_nlist (int ftp_stream, string directory); return value: array Function type: network system Content Description: This function is used to list all file names in the specified path. The ftp_stream parameter is the FTP connection code. The directory parameter is the specified directory. If the operation succeeds, an array of file names is returned. if the operation fails, a false value is returned.

Ftp_rawlistList all objects in a specified directory in detail. Syntax: array ftp_rawlist (int ftp_stream, string directory); return value: array Function type: network system Content Description: This function can list in detail the names of all files in the specified path. The ftp_stream parameter is the FTP connection code. The directory parameter is the specified directory. If the operation succeeds, an array of file names is returned. if the operation fails, a false value is returned.

Ftp_cmdypeDisplays the server system. Syntax: string ftp_0000ype (int ftp_stream); return value: string function type: Network System Description: This function displays the remote FTP server system, it is equivalent to the system or syst command on the FTP server. The ftp_stream parameter is the FTP connection code. If the call succeeds, a string is returned, for example, "215 UNIX Type: L8". if the call fails, a false value is returned.

Ftp_pasvSwitch the active/passive transmission mode. Syntax: boolean ftp_0000ype (int ftp_stream); return value: boolean function type: Network System Description: This function can be switched to active or passive transmission mode, it is equivalent to the passive or pass command under the FTP server. The ftp_stream parameter is the FTP connection code. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_getDownload an object. Syntax: boolean ftp_get (int ftp_stream, string local_file, string remote_file, int mode); return value: boolean function type: Network System Description: This function is used to download the specified file. The ftp_stream parameter is the FTP connection code. The local_file parameter is the name of the file to be saved as a local file. The remote_file parameter is the name of the file to be downloaded. The mode parameter has two types of values: FTP_ASCII and FTP_BINARY, indicating the text file Ning or binary file. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_fgetThe downloaded file exists in the opened file. Syntax: boolean ftp_fget (int ftp_stream, int fp, string remote_file, int mode); return value: boolean function type: network system Content Description: This function is used to download the specified file. The ftp_stream parameter is the FTP connection code. The parameter fp is the file pointer of an opened file on the local end. The remote_file parameter is the name of the file to be downloaded. The mode parameter has two types of values: FTP_ASCII and FTP_BINARY, indicating the text file Ning or binary file. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_putUpload a file. Syntax: boolean ftp_put (int ftp_stream, string remote_file, string local_file, int mode); return value: boolean function type: network system Content Description: This function is used to upload the specified file. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the name of the target remote object. The local_file parameter is the name of the file to be uploaded. The mode parameter has two types of values: FTP_ASCII and FTP_BINARY, indicating the text file Ning or binary file. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_fputUpload an opened file. Syntax: boolean ftp_fput (int ftp_stream, string remote_file, int fp, int mode); return value: boolean function type: network system Content Description: This function is used to upload the specified file. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the name of the target remote object. The fp parameter is the pointer to the opened file to be uploaded. The mode parameter has two types of values: FTP_ASCII and FTP_BINARY, indicating the text file Ning or binary file. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_sizeObtains the size of the specified file. Syntax: int ftp_size (int ftp_stream, string remote_file); return value: integer function type: network system Content Description: This function is used to obtain the size of the specified file on the FTP server. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the file name of the desired size. The returned value is the file size. if the file fails, the value-1 is returned.

Ftp_mdtmObtain the last modification time of the specified object. Syntax: int ftp_mdtm (int ftp_stream, string remote_file); return value: integer function type: network system Content Description: This function is used to obtain the last modification time of the specified file on the FTP server. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the file name for obtaining the modification time. The return value is in UNIX timestamp format. if the return value fails, the value-1 is returned.

Ftp_renameRename the file. Syntax: boolean ftp_rename (int ftp_stream, string from, string to); return value: boolean function type: Network System Description: This function can change the name of the file on the remote FTP server, note that the permissions cannot be changed if they do not match. The ftp_stream parameter is the FTP connection code. The parameter from is the original file name. The parameter to is the new file name to be modified. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_deleteDelete an object. Syntax: boolean ftp_delete (int ftp_stream, string remote_file); return value: boolean function type: network system Content Description: This function can delete files on the remote FTP server, if the permission does not match, it cannot be deleted. The ftp_stream parameter is the FTP connection code. The remote_file parameter is the name of the file to be deleted. If the call succeeds, the return value is true. if the call fails, the return value is false.

Ftp_quitDisable the FTP connection. Syntax: boolean ftp_quit (int ftp_stream); return value: boolean function type: Network System Description: This function is used to disable remote FTP server connection. The ftp_stream parameter is the FTP connection code. If the call succeeds, the return value is true. if the call fails, the return value is false.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.