如何使用php通过文件夹中的名称访问特定图像

时间:2019-06-27 10:18:09

标签: php

如何访问保存在文件夹中的图像,需要使用PHP通过其名称访问我能够访问完整的文件夹,但是我需要使用文件夹的名称进行访问。

 $dir = "images/";
   if (is_dir($dir)) {
     if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== false) {
        if($file == "ABC.png"){
       echo $lclImage[] = '<img src="http://localhost/images/'.$file.'" /><br>';
  }

    }
        closedir($dh);
      }
    }

如果该文件夹包含ABC.png和ABCD.png,则如果我输入ABC,则应该同时获得两个图像。

0 个答案:

没有答案