stat(), is_dir, is_file, etc... not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
StillGreen
Forum Newbie
Posts: 2
Joined: Mon Sep 30, 2002 11:02 pm
Location: Fargo

stat(), is_dir, is_file, etc... not working

Post by StillGreen »

I recently installed apache2, mySQL, and php4 on win98 (before I had MDAC installed) (newbie) and have the following problem...

functions like is_dir(), always return 0 whether it's a directory or not. The stat() functions return an error or no data. It seems as if these functions are finding no file or directory data, even though functions like fopen() will work. Is this a php problem? windows? apache? anyone have any ideas?
Jan
Forum Newbie
Posts: 1
Joined: Wed Oct 23, 2002 2:40 pm

Apache 2.0.43 / MySQL 3.23.52 / PHP 4.2.3 on RedHead Linux 7

Post by Jan »

I have exactly the same problem that you describe - except on Linux.

I had discovered this problem after uptating my LAMP-Architecture on my phpBB2-BulletinBord.
It comes into troble with file_exists() which does not work anymory.
After some nightly hours it looks like that the problem lies between Apache 2.0 and the new (?) API for PHP.

Jan.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

From the PHP Manual:-
[Editor's note: you need to pass either the correct relative or absolute path to the function]

is_dir() does not work correctly (i.e. returns false on some folders) unless you chdir() to folder that contains the file/folder you are checking.
[on Linux Red Hat 7.2]
and
Just as a quick addition to another comment, you must also chdir() on Windows machines.
Post Reply