Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is_dir problem...

Status
Not open for further replies.

iranor

Programmer
Jun 17, 2004
174
CA
I use PHP 4.3.4.

I'm used to programming, but I don't understand the problem here.

It looks like my is_dir() function think every folder is a file.

Let say I have the following directory:

test
test/1 -- Is a directory
test/2.jpg -- Is a file

$fp = opendir('test');
while ($file = readdir($fp)){
if ( $file != '.' && $file != '..' && !is_dir($file) ){
echo $file;
}
}

This will output no results.

$fp = opendir('test');
while ($file = readdir($fp)){
if ( $file != '.' && $file != '..' && is_dir($file) ){
echo $file;
}
}

I just removed the ! before the is_dir, and now it returns the .jpg file AND the directory :/

I also tried with is_file. If I use !is_file, all directorys and files appears. If I use is_file, nothing appears.
 
check what is the current directory when you're trying to use is_dir().
try to add
chdir('test');
after opendir
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top