This article mainly introduces how to establish an Ftp connection in php. The example analyzes the functions and usage skills related to FTP operations in php, which has some reference value, for more information about how to establish an Ftp connection with php, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
I read the ftp function today and summarized it as follows:
FTP related functions:
Ftp_connect (host, part, timeout) creates a new ftp connection. host is the server to be connected, and part is the port. the default value is 21, and timeout is the network connection timeout.
Ftp_login (con, user, password) is used to log on to ftp. con is an ftp connection established on the uplink. There are also user and password
Ftp_close (con) closes the con connection.
Ftp_pasv (con, true) enables con's passive transmission mode. Data is transmitted by the client. Of course, it can only be executed when the login is successful.
Ftp_put (con, remove, local, mode) upload the local path file to con and name it remove file. mode is transmission mode (FTP_ASCII, FTP_BINARY)
The following example:
$ Host = 'host'; $ user = 'user'; $ pwd = 'pwd'; $ con = ftp_connect ($ host); $ login = ftp_login ($ con, $ user, $ pwd); echo ftp_put('newname.txt', 'text.txt ', FTP_ASCII); ftp_close ($ con );
I hope this article will help you with php programming.