我是Web开发的初学者。我已经成功地将图像从我的文件夹移动到public_html下的hosterer文件夹,现在我需要在网站的画廊中显示这些图像。我如何使用php来做到这一点,我的文件夹名称是uploads。
您可以遍历该目录中的图像并在页面中回显它们:
$dir = "/uploads";
//get the list of all files with .jpg extension in the directory and safe it in an array named $images
$images = glob( $dir );
//extract only the name of the file without the extension and save in an array named $find
foreach( $images as $image ):
echo "<img src='" . $image . "' />";
endforeach;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句