Home >Backend Development >PHP Tutorial >PHP FTP operation
* FTP server
* //Connect to FTP server
* $conn = ftp_content(ftp.server.com);
* //Use username, password to log in
* ftp_login($conn,$username,$password);
* / /Get the remote system type
* ftp_systype($conn);
* //Get the current system directory
* ftp_pwd($conn);
* //List files
* $file_list = ftp_nlist($conn,". ");
* //Download file
* ftp_get($conn,"data.zip","data.zip",FTP_BINARY);
* //Close the connection
* ftp_quit($conn);
* //Passive Mode PASV
* ftp_pasv($conn,1);
* //Enter the directory, it accepts a directory name parameter
* ftp_chdir($conn, directory name);
* //Go back to the parent directory
* ftp_cdup ($conn);
* //Create a new directory, or move a directory
* ftp_mkdir($conn,"test"); If the creation is successful, the new directory name will be returned
* ftp_rmdir($conn,"test" );
* //Upload files
* ftp_put($conn,$src,$des,FTP_ASCII);
* $src: Uploaded file name
* $des: Uploaded file name
* FTP_ASCII: Upload form
* //Download file
* ftp_get($conn,$src,$des,FTP_ASCII);
* $src: Downloaded file name
* $des: Downloaded file name
* FTP_ASCII: Transmitted Form
*
* //Two ways to display a directory list:
* ftp_nlist(); only display the file name of the directory
* ftp_rawlist(); display the file name, permissions, creation time, and created role in the directory
* // Return the size of the file
* ftp_size(); Return the size of a file in BYTE, if -1 is returned, it is the directory
*
*
*
*/
The above has introduced the PHP FTP operation, including uploading files. I hope it will be helpful to friends who are interested in PHP tutorials.