Write ftp file upload with PHP

Source: Internet
Author: User
Tags ftp ftp connection ftp file

$ftp _server = "*.*.*.*";
$ftp _user = "Lu";
$ftp _pass = "Love You";

Set up a connection or die
$conn _id = ftp_connect ($ftp _server) or Die ("couldn ' t connect to $ftp _server");

$login _result = Ftp_login ($conn _id, $ftp _user, $ftp _pass);

if (! $conn _id) | | (! $login _result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp _server for user $ftp _user_name";
Exit
} else {
echo "Connected to $ftp _server, for user $ftp _user_name";
}

Try to login
$filename =date (' YMD '). XML ";
$source _file= "/usr/local/ivr/sendwireless/xml/data/". $filename; Source Address
echo $source _file;
$destination _file= "/itc/admin/logstat/ftplog/". $filename; Destination Address
$upload = Ftp_put ($conn _id, $destination _file, $source _file, ftp_binary) or Die ("couldn ' t connect to $ftp _server");
Ftp_quit ($conn _id);

if (! $upload) {
echo "FTP upload has failed!";
} else {
echo "uploaded $source _file to $ftp _server as $destination _file";
}
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.