Home  >  Article  >  Backend Development  >  File php ftp file upload function basic version

File php ftp file upload function basic version

WBOY
WBOYOriginal
2016-07-29 08:42:541010browse

Copy the 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";
}
// 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

The above introduces the basic version of the file php ftp file upload function, including file content. I hope it will be helpful to friends who are interested in PHP tutorials.

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