FTP Operation function Encyclopedia in PHP (function description)

Source: Internet
Author: User
Tags ftp connection remote ftp server
This article introduces the use of FTP operation function in PHP, the main function of the description, there is a need to refer to the friend.

FTP operation functions in PHP, mainly include:

Ftp_connect: Open the FTP link. Ftp_login: Log in to the FTP server. FTP_PWD: Get the current path. Ftp_cdup: Go back to the upper level directory. Ftp_chdir: Change the path. Ftp_mkdir: Build a new catalog. Ftp_rmdir: Delete directory. Ftp_nlist: Lists all files in the specified directory. Ftp_rawlist: Lists all files in the specified directory in detail. Ftp_systype: Displays the server system. FTP_PASV: Toggles the primary passive transfer mode. Ftp_get: Download the file. Ftp_fget: The file is downloaded and exists in the opened file. Ftp_put: Uploading files. Ftp_fput: Upload an open file. Ftp_size: Gets the size of the specified file. Ftp_mdtm: Gets the last modified time of the specified file. Ftp_rename: Rename the file. Ftp_delete: Delete the file. Ftp_quit: Closes the FTP connection.

The following is a detailed description of the FTP operation functions in PHP.

ftp_connect Open the FTP link. Syntax: int ftp_connect (string host, int [port]); return value: integer function type: Network system content Description: This function opens a link to the FTP server. The parameter host is the URL of the FTP server. Parameter port is usually omitted, if the FTP server port number (port) is not 21 o'clock need to add this parameter. Returns the connection code if there is no error, and returns a value of False if it fails. Reference: Ftp_quit ()

ftp_login Log in to the FTP server. Syntax: boolean ftp_login (int ftp_stream, string Username, string password); return value: Boolean function type: Network system content Description: This function can log into the linked FTP server. The Ftp_stream parameter is the FTP connection code. Parameters username and password are server user account and password, usually anonymous for public use account, password is Email. Success returns a true value.

ftp_pwd Get the current path. Syntax: string ftp_pwd (int ftp_stream); return value: String function type: Network system content Description: This function is used to obtain the current path in the FTP server. The Ftp_stream parameter is the FTP connection code. Returns a NULL value if there is an error.

Ftp_cdup back to the upper level 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, which is the parent directory of the current directory. The Ftp_stream parameter is the FTP connection code. Success returns a true value.

ftp_chdir Change the path. Syntax: boolean ftp_chdir (int ftp_stream, string directory); return value: Boolean function type: Network system content Description: This function is used to change the path. The Ftp_stream parameter is the FTP connection code. The parameter directory is the directory you want to go to. Success returns a true value, and a value of false if it fails.

Ftp_mkdir to build a new catalogue. 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 parameter directory is the new directory you want to create. Success returns the established directory name, and the failure returns a value of false.

ftp_rmdir Delete the directory. Syntax: boolean ftp_chdir (int ftp_stream, string directory); return value: Boolean function type: Network system content Description: This function is used to delete an empty directory. The Ftp_stream parameter is the FTP connection code. The parameters directory is the directory that you want to delete. Success returns a true value, and a value of false if it fails.

ftp_nlist Lists all files in the 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 parameters directory is the specified directory. Success returns an array of file names, and a value of False if failed.

ftp_rawlist Lists all files in the specified directory in detail. Syntax: array ftp_rawlist (int ftp_stream, string directory); return value: Array function type: Network system content Description: This function lists all the file names in the specified path in detail. The Ftp_stream parameter is the FTP connection code. The parameters directory is the specified directory. Success returns an array of file names, and a value of False if failed.

ftp_systype Displays the server system. Syntax: string ftp_systype (int ftp_stream); return value: String function type: Network system content Description: This function can display the remote FTP server system, it is equal to the FTP server under system or Syst instructions. The Ftp_stream parameter is the FTP connection code. Success returns a string, such as "215 UNIX Type:l8", which returns a value of False if it fails.

FTP_PASV Switch The primary passive transmission mode. Syntax: boolean ftp_systype (int ftp_stream); return value: Boolean function type: Network system content Description: This function can be switched to active transmission or passive transmission mode, it is equal to the FTP server under the passive or pass instructions. The Ftp_stream parameter is the FTP connection code. Success returns a true value, and a value of false if it fails.

ftp_get Download the file. Syntax: boolean ftp_get (int ftp_stream, string local_file, 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 local_file is the file name to save the cost to. The parameter remote_file is the name of the file you want to download. The value of the parameter mode is FTP_ASCII and Ftp_binary two, respectively, indicating the text file ning or binary file. Success returns a true value, and a value of false if it fails.

ftp_fget Downloads the file and exists in the file that is already open. 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. Parameter FP is a file pointer to the open file on the local side. The parameter remote_file is the name of the file you want to download. The value of the parameter mode is FTP_ASCII and Ftp_binary two, respectively, indicating the text file ning or binary file. Success returns a true value, and a value of false if it fails.

ftp_put upload files. 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 parameter remote_file is the file name to which the remote is to exist. The parameter local_file is the file name of the file to be uploaded. The value of the parameter mode is FTP_ASCII and Ftp_binary two, respectively, indicating the text file ning or binary file. Success returns a true value, and a value of false if it fails.

ftp_fput upload an open 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 parameter remote_file is the file name to which the remote is to exist. The parameter FP is the open file file pointer that you want to upload. The value of the parameter mode is FTP_ASCII and Ftp_binary two, respectively, indicating the text file ning or binary file. Success returns a true value, and a value of false if it fails.

ftp_size Gets 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. Parameter remote_file to get the size file name. The return value is a file size, and a value of 1 is returned if it fails.

Ftp_mdtm Gets the last modified time of the specified file. 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 parameter remote_file is the name of the file to get the modified time. The return value is a UNIX time format (timestamp), and a value of 1 is returned for failure.

ftp_rename Rename the file. Syntax: boolean ftp_rename (int ftp_stream, string from, string to); return value: Boolean function type: Network system content Description: This function can be the remote FTP server file name change, the value of the attention is not the permissions do not Change of law. 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 that you want to change. Success returns a true value, and a value of false if it fails.

ftp_delete Delete the file. Syntax: boolean ftp_delete (int ftp_stream, string remote_file); return value: Boolean function type: Network system content Description: This function can be remote FTP server file deletion, if the permissions do not delete. The Ftp_stream parameter is the FTP connection code. The parameter remote_file is the name of the file you want to delete. Success returns a true value, and a value of false if it fails.

ftp_quit Close the FTP connection. Syntax: boolean ftp_quit (int ftp_stream); return value: Boolean function type: Network system content Description: This function is used to close the remote FTP server connection. The Ftp_stream parameter is the FTP connection code. Success returns a true value, and a value of false if it fails.

  • Related Article

    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.