PHP ftp function File upload

Source: Internet
Author: User
Tags ftp connection php file upload
Many times we will not be used for PHP ftp function file upload, but in the use of more advanced Web applications will be used in the FTP function, such as I now upload the image of the B server, data saved to a server, ordinary php file upload instance, but with the FTP function can be convenient instance, The code is as follows:

<?php

Defining variables

$local _file = ' local.zip ';

$server _file = ' server.zip ';

Connecting to an FTP server

$conn _id = ftp_connect ($ftp _server);

Verifying the logon server

$login _result = Ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);

Download file

if (Ftp_get ($conn _id, $local _file, $server _file, ftp_binary)) {

echo "Download $local _file file succeeded";

} else {//Open source code phpfensi.com

echo "failed to download";

}

Close FTP connection

Ftp_close ($conn _id);

?>

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