我有一个脚本,每天进行一次sql备份并将其存储到我的服务器(大约20MB)。之后,我想将文件发送到我的办公室NAS,但我收到错误" ftp_put():打开ASCII模式数据连接"。 Actualy是一个500内部服务器错误,在错误日志中我得到" ftp_put():为bn_170930011208.sql打开ASCII模式数据连接"
虽然该文件已转移到NAS但不完全。
我尝试将模式更改为BINARY但仍然出错。
有什么建议吗?
以下是代码:
<?php
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
$file = "/home/USER/public_html/_backup/bn_170930011208.sql";
$conn_id = ftp_connect('MY_DYNDNS_OFFICE_NAS_ADDRESS') or die("Can't connect");
$login_result = ftp_login($conn_id, "USER", "PASS")or die("Can't login");
ftp_pasv($conn_id, true);
ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 300);
// change the directory
if (ftp_chdir($conn_id, "web/bn/")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
} else {
echo "Couldn't change directory\n";
}
// upload file
if (ftp_put($conn_id, "bn_170930011208.sql", $file, FTP_ASCII))
{
echo "Successfully uploaded $file.";
}
else
{
echo "Error uploading $file.";
}
// close connection
ftp_close($conn_id);
?>