当前目录中的图像未显示

编程入门 行业动态 更新时间:2024-10-22 20:22:20
本文介绍了当前目录中的图像未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用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{

更多推荐

当前目录中的图像未显示

本文发布于:2023-11-02 08:18:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551868.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   目录中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!