FTP Upload download file

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

Upload file:

<?PHP/** * FTP upload file*/$ftp _server='localhost';//Server$ftp _port=' +';//Port$ftp _user_name='FTP';//User name$ftp _user_pass='zxcasdqwe123';//Password$ftp _put_dir='/root';//Upload Directory$ftp _conn_id=Ftp_connect ($ftp _server, $ftp _port); $ftp _login_result=Ftp_login ($ftp _conn_id, $ftp _user_name, $ftp _user_pass);if((! $ftp _conn_id) | | (!$ftp _login_result)) {echo'failed to connect to FTP server'; Exit;}Else{FTP_PASV ($ftp _conn_id,true);//return to the mode, some FTP server must execute this sentenceFtp_chdir ($ftp _conn_id, $ftp _put_dir); $ftp _upload= Ftp_put ($ftp _conn_id,'Db.sql','Db.sql', ftp_binary); //var_dump ($ftp _upload);//See if the write succeedsFtp_close ($ftp _conn_id);//Disconnect}?>

Download file:

<?PHP//Defining Variables$local _file ='Local_file.zip'; $server _file='Remote_file.zip';//connecting to an FTP server$conn _id =Ftp_connect ($ftp _server);//Verifying the logon server$ftp _user_name ="Ftp_user1"; $ftp _user_pass="123456_123456"; $login _result=Ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);//Download Fileif(Ftp_get ($conn _id, $local _file, $server _file, ftp_binary)) {echo"Download $local _file file Success N";} Else{echo"Download failed n";}//Close FTP Connectionftp_close ($conn _id);?>

FTP Upload download file

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.