我正在尝试上传通过
PHP从数据库创建的文本文件.
文本文件创建正常,但是当我尝试通过PHP FTP上传文件时,它就失败了.
我的代码:
$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,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不同.在第100行/home/sites/mysite.co.uk/public_html/admin/controllers/generate_Feed.PHP错误:无法将products_admin.txt上传到uploads.google.com.
您可能只需要激活被动模式:
原文链接:https://www.f2er.com/php/136357.html... $login_result = ftp_login($ftp_connect,"{passwordhere}") or die("ERROR: Username or Password incorrect."); ftp_pasv($ftp_connect,true); ...