我正在尝试上传通过 PHP 从数据库创建的文本文件。
文本文件创建正常,但是当我尝试通过 PHP FTP Put 上传文件时失败。
我的代码:
$filename = "products_admin.txt";
$handle = fopen($filename, 'w+');
fwrite($handle, $content);
fclose($handle);
echo "Attempting to connect to <i>uploads.google.com</i>...<br />";
$ftp_connect = ftp_connect("uploads.google.com", "21", "5000") or die("failed to connect.");
$login_result = ftp_login($ftp_connect, "{usernamehere}", "{passwordhere}") or die("ERROR: Username or Password incorrect.");
if((!$ftp_connect) || (!$login_result)) {
echo "ERROR: Couldn't connect to <i>uploads.google.com</i>, upload failed.<br /><br />";
echo "<a href=\"javascript:location.reload(true)\">Try Again</a>";
exit;
} else {
echo "Connected to <i>uploads.google.com</i>...<br />";
$upload = ftp_put($ftp_connect, $filename, $filename, FTP_ASCII);
if(!$upload) {
echo "ERROR: Failed to upload ".$filename." to <i>uploads.google.com</i>.<br /><br />";
echo "<a href=\"javascript:location.reload(true)\">Try Again</a>";
} else {
echo "Uploading <i>".$filename."</i> to <i>Froogle</i>...<br />";
echo "Successfully uploaded <i>".$filename."</i> to <i>uploads.google.com</i>.<br /><br />";
echo "Done.";
}
}
ftp_close($ftp_connect);
我得到的错误信息是
警告:ftp_put(): PORT IP 与 176.32.230.48 不同。在 /home/sites/mysite.co.uk/public_html/admin/controllers/generate_feed.php 第 100 行错误:无法将 products_admin.txt 上传到 uploads.google.com。