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>"; }} ?> Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/ 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. Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478652 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 Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478657 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? Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478660 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 Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478663 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? Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478666 Share on other sites More sharing options...
amwd07 Posted February 28, 2008 Author Share Posted February 28, 2008 absolute genius I love this forum Link to comment https://forums.phpfreaks.com/topic/93429-php-glob-help/#findComment-478669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.