我有两台服务器。我正在连接的文件中已经有一个 .txt 文件。
我需要获取 .txt 文件内容并将它们放入$
变量中。这是我的代码不起作用:
$ftp_server = $_POST["site"];
$path = $_POST["path"];
$ftp_user_name = $_POST["username"];
$ftp_user_pass = $_POST["pass"];
// 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);
$remote_filename =
"/" . $_POST["path"] . "/" . "#" . $result["id"]
. " - " . $result["LastName"] . ", " . $result["FirstName"]
. "/" . $_POST["title"] . ".txt";
ftp_get($conn_id, $content, $remote_filename, FTP_ASCII);
此代码连接到 FTP,我使用它ftp_get
从一个文本文件复制到一个名为$content
. 我知道一个变量不属于这个参数,但我现在被卖掉了。我不知道如何阅读这个 .txt 文件。
有没有办法用 PHP FTP 函数做到这一点?
现在,当我尝试这个时:
$fileContents = file_get_contents('ftp://username:password@hostname/path/to/file');
它给出了一个错误:
警告:fopen(ftp://...@goldenbooklet.com/101Notebook Backup:22-08-2013/#11 - Cappucci,Ryan/queen.txt)[function.fopen]:无法打开流:FTP 服务器报告550 /101笔记本备份:22-08-2013/:不是第 269 行 /home/content/34/11614434/html/adminpdo.php 中的常规文件
为什么我会收到此错误?
再次感谢