gpt4 book ai didi

PHP连接到FTP服务器

转载 作者:行者123 更新时间:2023-11-29 05:35:26 25 4
gpt4 key购买 nike

你好,我有连接到我的 ftp 服务器的代码

$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
//ftp_mkdir($conn_id, $dir);
$contents = ftp_nlist($conn_id, $dir);
//var_dump($contents);
echo "<select name=\"file\">\n";
// Now loop through the files, echoing out a new select option for each one
if (($contents != '.') && ($contents != '..') )
{

foreach( $contents as $fname )

{
echo "<option>{$fname}</option>\n";
}
echo "</select>\n";

}
}

但该页面仍将目录回显为 . & .. 尽管有 $contents != bit;缺少什么?

改成了这个->

if (($fname != '.')  && ($fname != '..') ) 
{

foreach( $contents as $fname )

{
echo "<option>{$fname}</option>\n";
}
echo "</select>\n";

}
}

结果还是一样

最佳答案

您可能想将循环内的 $fname... 进行比较。这可能是您想要的更多内容。

关于PHP连接到FTP服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11110358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com