The ultimate solution of ftp_connect for php in centos

Source: Internet
Author: User
Tags ftp connection

The ultimate solution of ftp_connect for php in centos
Uploading images through FTP in the test php today. After the code is written, there is no problem in testing in the win system, but in centos, it is basically invalid.

Check and find that the connection to Step 1 ftp_connect fails.

Almost no complete solution is available in Baidu. You can only find the cause step by step.

Finally, the first problem was found. The FTP component was not installed. Solution: refer to the FTP component installation process record in centos.

After the first problem is solved, apache cannot be connected again. It's annoying!

Check the firewall and permissions. No problem ............

Finally, the second problem was found. After SELinux was closed, the FTP connection was normal ............

Solution: Refer to SELinux introduction and close

The following is a simple FTP function:

$ Ftpserver = ""; $ conn = ftp_connect ($ ftpserver); // open the connection. The default value is port 21. Therefore, ftp_login ($ conn, 'root ', '000000'); // authenticate ftp_pasv ($ conn, 1); // open the passive mode ftp_put(+conn,'1.txt','1.txt ', FTP_BINARY); // transfer the file ftp_close ($ conn); // close the connection

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: 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.