Php 获取文件夹中的所有文件夹和图像列表
库文件夹中的目录是动态创建的。我正在尝试访问其中的文件夹和相应的图像。根据,现在我访问了文件夹,但没有在其中获取图像。如何循环与目录对应的所有图像。 请帮我解决这个问题Php 获取文件夹中的所有文件夹和图像列表,php,Php,库文件夹中的目录是动态创建的。我正在尝试访问其中的文件夹和相应的图像。根据,现在我访问了文件夹,但没有在其中获取图像。如何循环与目录对应的所有图像。 请帮我解决这个问题 <?php #default directory $dir = '../gallery/'; $files1 = scandir($dir); #open a gallery directory if ($handle = opendir($dir)) { #read all the directories i
<?php
#default directory
$dir = '../gallery/';
$files1 = scandir($dir);
#open a gallery directory
if ($handle = opendir($dir)) {
#read all the directories inside a gallery folder
while($file = readdir($handle)){
if($file !== '.' && $file !== '..'){
#get all images inside variable $file
echo '<img src="../gallery/'.$file.'/" border="0" height="100" width="150"/>';
}
}
}
?>
foreach(glob(“../gallery/”“*”)作为$filename){
回声';
}
Why notglob()
是的,我尝试过,但无法循环。在这里,我只能检索文件夹,但无法检索其中的图像。路径正确。这是我正在运行的项目。gallery文件夹在test123中
foreach(glob("../gallery/".'*') as $filename) {
echo '<img src="../gallery/'.basename($filename).'/" border="0" height="100" width="150"/>';
}