打开 FTP 个文件问题
Open FTP file Issue
我正在尝试使用以下行打开 ftp 文件,
$con = ftp_connect(myhost);
if (!$con) {
throw new Exception('Unable to connect');
}
$loggedIn = ftp_login($con, 'user', 'pass');
if ($loggedIn) {
if(ftp_get($con, test.csv, "ftp://myhost/test.csv", FTP_ASCII))
echo 'in';
else
echo 'out';
}
然后我收到错误
ftp_get(): File not found
但是如果我在浏览器中 运行 ftp 路径它会正确获取文件。
谁能指导我走正确的道路??提前致谢
你最好的选择是 ftp_get()
:
$con = ftp_connect(myhost);
// try to download $server_file and save to $local_file
if (ftp_get($con, 'file_to_save_to.csv', 'test.csv', FTP_BINARY)) {
echo "Successfully written";
} else {
echo "There was a problem\n";
}
作为:
FTP is an insecure protocol. The credentials are passed in clear text
to the server and can be sniffed. Consider using SFTP or another more
secure solution.
我正在尝试使用以下行打开 ftp 文件,
$con = ftp_connect(myhost);
if (!$con) {
throw new Exception('Unable to connect');
}
$loggedIn = ftp_login($con, 'user', 'pass');
if ($loggedIn) {
if(ftp_get($con, test.csv, "ftp://myhost/test.csv", FTP_ASCII))
echo 'in';
else
echo 'out';
}
然后我收到错误
ftp_get(): File not found
但是如果我在浏览器中 运行 ftp 路径它会正确获取文件。
谁能指导我走正确的道路??提前致谢
你最好的选择是 ftp_get()
:
$con = ftp_connect(myhost);
// try to download $server_file and save to $local_file
if (ftp_get($con, 'file_to_save_to.csv', 'test.csv', FTP_BINARY)) {
echo "Successfully written";
} else {
echo "There was a problem\n";
}
作为
FTP is an insecure protocol. The credentials are passed in clear text to the server and can be sniffed. Consider using SFTP or another more secure solution.