glob函数 循环遍历子目录下的文件

时间:2022-09-01 23:25:16
<?php 
foreach (glob("ueditor\php\upload\image\*\*.png") as $filename) { 
   echo "$filename size " . filesize($filename) . "\n"; 
} 
?> 

 

<?php 

$file = "ueditor\php\upload\image\*\*.png";
foreach (glob("$file") as $filename) 
{
   echo "<img src=\"".$filename."\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
   echo "<a href=\"".$filename."\">".$filename."</a><br/><br/><br/>";
  
}


//foreach (glob("*.txt") as $filename) {
   //echo "$filename size " . filesize($filename) . "\n";
   //unlink($filename);
//}


//array_map('unlink', glob("*.txt")); 


//$file = "ueditor\php\upload\image\*\*.png";
//foreach (glob("$file") as $filename) 
//{
   //echo "<img src=\"".$filename."\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
   //echo "<a href=\"".$filename."\">".$filename."</a><br/><br/><br/>";
   
//}


//foreach (glob("ueditor\php\upload\image\*\*.png") as $filename) 
//{
   //echo "<a href=\"".$filename."\">".$filename."</a><br/>";
//}


//foreach (glob("ueditor\php\upload\image\*\*.png") as $filename) { 
   //echo "$filename size " . filesize($filename) . "\n"; 
//} 


?> 
<script type="text/javascript" src="tp.php?action=test"></script>