amwd07 Posted February 28, 2008 Share Posted February 28, 2008 I have this simple code below which currently doen't work ??? all I am trying to do is display Replace Image if files exist in the specific directory not sure where I'm going wrong? <?php $dine = $_GET['dine_id']; foreach (glob("{*.jpg,*.JPG,*.gif,*.GIF}",GLOB_BRACE) as $file) { if(file_exists("/outlet/id/$dine/".$file)) { echo "<span><a href=#>Replace Image</a></span>"; }} ?> Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 Sorry, what results are you expecting and what are you actually getting? Your question/problem is quite unclear. Quote Link to comment Share on other sites More sharing options...
amwd07 Posted February 28, 2008 Author Share Posted February 28, 2008 Sorry I will try to explain clearer $dine represents the venues id each venue will have it own image library I want to be able to check if any files exist in the folder if this comes back true display Replace Image. The replace image page shows all the files in specific directory ie. outlet/id/185 //// all images show up in this directory but if there are none don't display the replace image link Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 So, the result you are currently getting is what again? Quote Link to comment Share on other sites More sharing options...
amwd07 Posted February 28, 2008 Author Share Posted February 28, 2008 the replace image is not showing on the page so as far as I can see something must be broken in the script it is looking in the right directory but there are files in the directory so the replace image should be displayed Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 Yoiur call to glob looks in the current directory, this doesn't look right to me. Maybe something like... <?php $files = array(); $dine = $_GET['dine_id']; $files = glob("/outlet/id/$dine/{*.jpg,*.JPG,*.gif,*.GIF}",GLOB_BRACE); if (count($files)) { echo "<span><a href=#>Replace Image</a></span>"; } ?> is more like what your after? Quote Link to comment Share on other sites More sharing options...
amwd07 Posted February 28, 2008 Author Share Posted February 28, 2008 absolute genius I love this forum Quote Link to comment 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.