我可以在本地设置上运行此文件并获取所有文件名,但无法在网络服务器上运行。
这是我的代码:
$log_directory = getcwd()."/Episode".$epNum;
$dir = "/images/Episode1";
// Open a directory, and read its contents
if (is_dir($log_directory)){
if ($dh = opendir($log_directory)){
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
closedir($dh);
}
}
答案 0 :(得分:2)
嘿,您可以使用以下代码在任何目录中获取所有文件夹名称
<select >
<option value="">Select folder </option>
<?php $dir = 'mainfolder'; //this is your main dir
$files = scandir($dir, 0);
for($i = 2; $i < count($files); $i++)//the below code will show aall folder name inside the folder "mainfolder"
{
?>
<option value="<?php echo $files[$i]; ?>" ><?php echo $files[$i]; ?> </option>
<?php
}
?>