pcw Posted April 27, 2009 Share Posted April 27, 2009 Hi, I am having a problem with the following script. It prints out the filename for each of the images in the directory but just shows a red cross instead of the image. When I click on properties on the right click menu of the red cross, it shows the wrong directory path. I dont know why, and cant work out how to fix this <?php $username = "paul2"; $path = "../../members/uploads/$username/"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if($file == ".") continue; if($file == "..") continue; echo "<form action=img.php method=POST>"; echo "<input type=CHECKBOX name=$file>"; echo "<img src='$file' alt='$file'><br />"; echo "<input type=submit name=delete value=Delete>"; echo "</form>"; } closedir($dir_handle); ?> The code for this is different from an earlier post I made for showing an image for each upload and I cannot use it to solve this problem. Quote Link to comment https://forums.phpfreaks.com/topic/155885-solved-show-images-that-are-listed-in-directory/ Share on other sites More sharing options...
ignace Posted April 27, 2009 Share Posted April 27, 2009 instead of reading it yourself you could also just use scandir() http://be2.php.net/manual/en/function.scandir.php btw if($file == ".") continue; if($file == "..") continue; is the same as: if ($file[0] === '.') continue; which also covers both Quote Link to comment https://forums.phpfreaks.com/topic/155885-solved-show-images-that-are-listed-in-directory/#findComment-820543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.