我需要php脚本来列出远程帐户上的文件夹和文件;就像在这个例子中一样(这个屏幕在localhost中)
我也试过这段代码,但它没有用
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
if (@ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
echo "Connected as $ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user_name\n";
}
$contents = ftp_nlist($conn_id, "css/") or die("Couldn't read to $ftp_server");
echo $contents;
不幸的是在控制台中我看到了
Connected as atollosrl@ftp.atollosrl.com
Couldn't read to ftp.atollosrl.com
代码到达时
$contents = ftp_nlist($conn_id, "css/") or die("Couldn't read to $ftp_server");
它死了。
解决。
现在,此代码可以从ftp_nlist
更改为ftp_rawlist
:)
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
if (@ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
echo "Connected as $ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user_name\n";
}
$contents = ftp_rawlist($conn_id, "/") or die("Couldn't read to $ftp_server");
echo $contents;
答案 0 :(得分:-1)
<?php
exec("dir", $output, $return);
echo "Dir returned $return, and output:\n";
var_dump($output);
?>
对于Windows和一些unix机器