php ftp function file upload

高洛峰
Release: 2016-11-29 15:09:25
Original
1083 people have browsed it

Many times we don’t use the php ftp function to upload files, but we will use the ftp function when using more advanced WEB applications. For example, I want to transfer the uploaded pictures to server B and save the data to server A. Normally The php file upload example cannot be used, but it can be easily done using the ftp function. The code is as follows:

// Define variables

$local_file = 'local.zip';

$server_file = ' server.zip';

//Connect to FTP server

$conn_id = ftp_connect($ftp_server);

//Verify login 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 successfully";

} else {//Open source code phpfensi.com

echo "Download Failure ";

}

//Close ftp connection

ftp_close($conn_id);

?>


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template