This can display a picture, but what should I do if I want to display all the pictures in the img folder? It doesn't work if I change it to $url = 'upload/'; So what should I do?
<code>header("Content-Type: image/jpeg;text/html; charset=utf-8"); $url='1.jpg'; $img = file_get_contents($url,true); echo $img;</code>
This can display a picture, but what should I do if I want to display all the pictures in the img folder? It doesn't work if I change it to $url = 'upload/'; So what should I do?
<code>header("Content-Type: image/jpeg;text/html; charset=utf-8"); $url='1.jpg'; $img = file_get_contents($url,true); echo $img;</code>
There are many methods, examples are as follows
<code>$dir = "upload/"; //要获取的目录 if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh))!= false){ $filePath = $dir.$file; echo "<img src='".$filePath."'/>"; } closedir($dh); } }</code>