Home > Article > Backend Development > php ftp function file upload_PHP tutorial
Many other times we will not use the php ftp function to upload files, but when using more advanced WEB applications, we will use the ftp function. For example, I now want to transfer the uploaded pictures to server B and save the data to server A. , the ordinary PHP file uploading example cannot be used, but it can be easily implemented using the ftp function.
We will not use the ftp function file upload in PHP tutorials many other times, but we will use the ftp function when using more advanced WEB applications. For example, I now want to transfer the uploaded pictures to the B server and data. When saved to server A, ordinary PHP file uploading cannot be used, but it can be easily done using the ftp function.
//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 n";
} else {
echo "Download failed n";
}
// Close ftp connection
ftp_close($conn_id);
?>