How to establish an Ftp connection in php

Source: Internet
Author: User
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.

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.