Home  >  Article  >  Backend Development  >  php ftp file upload function (basic version)_PHP tutorial

php ftp file upload function (basic version)_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:36:59856browse

Copy code 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 {
echo "Download failed n";
}
// Close ftp connection
ftp_close($conn_id);
?>

ftp_connect — Establish a new FTP connection
ftp_login — Log in to the FTP server
ftp_get — Download a file from the FTP server

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322017.htmlTechArticleCopy the code as follows: ?php // Define variable $local_file = 'local.zip'; $server_file = ' server.zip'; // Connect to FTP server $conn_id = ftp_connect($ftp_server); // Verify login service...
Statement:
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