本文介绍了当前目录中的图像未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用php脚本显示当前目录中的所有图像。显示图像的php文件也在同一目录中。这是脚本
<?php $ dir = basename(__ DIR__); if (file_exists($ dir)== false) { echo ' 目录\''。 $目录。 ' \'not found!'; } else { $ dir_contents = scandir($ dir); foreach ($ dir_contents as $ file) { $ file_type = strtolower(end(explode(' 。',$ file))); if ($ file!== ' 。'&& $ file !== ' ..'&& in_array($ file_type,$ file_display)== true) { echo ' < img src ='。$ dir。' /'。$ file。' alt ='。$ file。' /> ;'; } ?>输出显示no目录存在。但我已经看到该目录存在。请告诉我我的代码有什么问题谢谢
解决方案dir = basename(__ DIR__); if (file_exists(
dir)== false) { echo ' 目录\''。 DIR。 ' \'not found!'; } else {
I am trying to show all images from my current directory using php script. the php file which is showing image also is in the same directory. here is the script
<?php $dir =basename(__DIR__); if (file_exists($dir) == false) { echo 'Directory \''. $dir. '\' not found!'; } else{ $dir_contents = scandir($dir); foreach ($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) { echo '<img src="'.$dir. '/'.$file. '" alt="'.$file. '" />'; } } } ?>the output says the no directory exists. but i have seen the directory exists. please tell me whats wrong with my code Thanks
解决方案 dir =basename(__DIR__); if (file_exists(dir) == false) { echo 'Directory \''.dir. '\' not found!'; } else{更多推荐
当前目录中的图像未显示
发布评论