How to implement FTP upload basic code in PHP

Source: Internet
Author: User

FTP tools we have used to upload files, then in PHP, how to use code to achieve it, the following simple introduction of a most basic example, first, according to our use of FTP tools, to achieve file upload need to open the FTP tool-> input FTP address, port number, account, Password login ftp-> from the local selection of the appropriate files uploaded to the FTP directory, PHP to achieve such a simple function is nothing more.

First Step: Open FTP

$ip = "101.101.101.101";

$name = "name";

$pwd = "Mima";

$con =ftp_connect ($ip, "a") or ("Connection failed");

Step Two: Landing ftp

Ftp_login ($con, $name, $pwd);

Step three: Upload the local test.php file to the FTP image directory

Ftp_put ($con, "ittest/test.php", "test.php", ftp_ascii);

At this point in the FTP image directory can see test.php file, of course, upload files here, you can expand the upload form, the form attachment upload ftp This is more convenient, here only as a file most basic upload FTP function.

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.