mandrill Posted September 21, 2006 Share Posted September 21, 2006 The is-dir function isn't recognising a directory. here's the code:[code]<?php/* Keiths Gallery ProjectPurpose: To dynamically list files and directories and display them as galleries on my websiteStep one: define variables */$rootdir="the/directory/i/want/read";// Step two: generate array of subdirectories of the directory. These will be my galleries organised according to subject matter$dh=opendir($rootdir);while ($filename = readdir($dh)) { $rootdircont[] = $filename; }foreach($rootdircont as $image) { echo"$image"; var_dump(is_dir($image)); echo"</br>"; }echo"$</br>";$counter = 0 ;foreach ($rootdircont as $file) { if ( is_dir($file)) { $counter ++ ; echo "$counter: $file</br>"; $galarray[$counter] = $file; } }/* test echo of above */echo '</br>';foreach ($galarray as $galdir){ echo "$galdir</br>";}?>[/code]here's the output:[code].bool(true)..bool(true)atomfeedbtn.pngbool(false)readme.txtbool(false)43things.pngbool(false)ap-search-go-btn.gifbool(false)arthurbool(false) <-------------- This is a directory but its not being recognised as one.bc80x15gold.gifbool(false)blogoramabutton.gifbool(false)button_sm_1.gifbool(false)deliciousbutt.pngbool(false)firefox_80x15.pngbool(false)goblink.gifbool(false)icon_scotland_80x15.gifbool(false)index.htmlbool(false)lcabutton.pngbool(false)onepointthreebanner.jpgbool(false)popdexbtn.pngbool(false)right2writebtn.pngbool(false)rssfeedbtn.pngbool(false)scotblogsbtn.gifbool(false)Thumbs.dbbool(false)ucrated.pngbool(false)ucv12title.jpgbool(false)wika-blogbtn.pngbool(false)Cloud.pngbool(false)button6.gifbool(false)Dawn_Of_Skirmish_v1.6_AI_Mod_Install.exebool(false)egobutton.pngbool(false)searchbox-logo-126x32.gifbool(false)zardozzbtn.pngbool(false)logo_80x15.gifbool(false)libertybutt.pngbool(false)wp-logos-buttons.jpgbool(false)wp-button-3.pngbool(false)tn-tiny.gifbool(false)$1: .[/code]Its probably something really stupid but I'd appreciate it if someone could point it out to me, cos I've been staring at it for hours and getting nowhere.thanks Quote Link to comment https://forums.phpfreaks.com/topic/21553-is_dir-not-working/ Share on other sites More sharing options...
Daniel0 Posted September 21, 2006 Share Posted September 21, 2006 Do the webserver have read permissions to the folder? I am not sure if this could be it, but lets just check it. Quote Link to comment https://forums.phpfreaks.com/topic/21553-is_dir-not-working/#findComment-96173 Share on other sites More sharing options...
sasa Posted September 21, 2006 Share Posted September 21, 2006 [code]change[codevar_dump(is_dir($image));][/code]to[code]var_dump(is_dir($rootdir.'/'.$image));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21553-is_dir-not-working/#findComment-96183 Share on other sites More sharing options...
mandrill Posted September 21, 2006 Author Share Posted September 21, 2006 bingo sasa that did it thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/21553-is_dir-not-working/#findComment-96338 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.