我的网络服务器上有大文件(总共约250mb)。我想在不使用ftp客户端的情况下将这些文件快速发送到我的第二台服务器。我知道我的第二台服务器的ftp密码,用户名等,但如果没有ftp客户端怎么办?
答案 0 :(得分:1)
$file = 'somehugefile.big';
$remote_file = '/uploads/somehugefile.big';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
此示例改编自官方文档 - > http://www.php.net/manual/en/function.ftp-put.php
您还必须将PHP.ini中的'upload_max_filesize'和'post_max_size'更改为更高的值。
ini_set('upload_max_filesize', '250M');
ini_set('max_execution_time', '999');
ini_set('memory_limit', '500M');
ini_set('post_max_size', '250M');