有乎-价值、共享、信任

What you care about-value, sharing, trust

PHP读出指定目录下的文件,如果是JPG则直接显示出来

| 阅读:1674 发表时间:2021-11-29 10:13:40 技术专栏

只需要掌握两个方法:opendir  【打开目录】  readdir【读取目录下的文件】

$path1 = 'dir';

$handle = opendir($path1);
	while (false !== ($file = readdir($handle))) {
		$tmp =explode(".",$file);
		if($tmp[1] == 'jpg'){
		    echo "<img src='".$path1.'/'.iconv('GBK','UTF-8',$file)."'/>";
			echo "<center style='font-size:16px;font-weight:bold;padding:20px 0;background:white;margin-top:-10px;'>".iconv('GBK','UTF-8',$file)."</center>";
		}
	}
*文章为作者独立观点,不代表【uuuho有乎】的立场
本文由【uuuho有乎】发表并编辑,转载此文章须经作者同意,并请附上出处及本页链接。如有侵权,请联系本站删除。

Who are we?