Jump to content

Archived

This topic is now archived and is closed to further replies.

mandrill

is_dir not working.

Recommended Posts

The is-dir function isn't recognising a directory. here's the code:
[code]<?php

/* Keiths Gallery Project
Purpose: To dynamically list files and directories and display them as galleries on my website
Step 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

Share this post


Link to post
Share on other sites
Do the webserver have read permissions to the folder? I am not sure if this could be it, but lets just check it.

Share this post


Link to post
Share on other sites
[code]change[codevar_dump(is_dir($image));][/code]to[code]var_dump(is_dir($rootdir.'/'.$image));[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.