Page 1 of 1

Files not seen as files (and won't unlink)

Posted: Sat Dec 25, 2004 2:44 am
by seveninstl
I have created a script to backup a database. The script first checks for the day, then uses the day's name for the directory (Sunday, Monday, Tuesday, etc.). Then it deletes all files from that directory. Finally, it 'creates/saves' the new files to the directory.

Ok, the problem:
In one directory, the is_file() does not recognize the files as files... it reads them (using $dirName->read()), but NO files in this directory pass the is_file() test. To make things more curious, the files are also not deleted by unlink(). The is_dir() test works fine and reads . and .. as directories. The files are not mistaken for directories either.

The permissions on the directories are all the same (0777). The script is running as a cron job and it 'logs in' as the same user each day.

Server: Linux/Apache 2.0, PHP 4.3.8

Anyone got any ideas?? Thanks!

Posted: Sat Dec 25, 2004 11:20 am
by Chris Corbyn
Can we see some code please?

Solved

Posted: Sat Dec 25, 2004 11:27 am
by seveninstl
Solved it myself (with indirect help). In case anyone is wondering what I did...

I changed my search criteria this morning and found other posts that were similar to mine. In one "timvw" gave some advice that I tried and it worked.

I was using:

Code: Select all

<?php
if (is_file($contents))
?>
But should have been using:

Code: Select all

<?php
if (is_file($dirName->path."/".$contents))
?>
I'm not really sure why my original code worked on some directories and not others. But, by adding the path, it now works on all directories.

Thanks timvw, even if the help was indirect :)

Posted: Sat Dec 25, 2004 11:37 am
by Chris Corbyn
Good stuff :-)