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

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
seveninstl
Forum Newbie
Posts: 4
Joined: Fri May 14, 2004 12:38 pm
Location: Kissimmee, FL

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

Post 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!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Can we see some code please?
seveninstl
Forum Newbie
Posts: 4
Joined: Fri May 14, 2004 12:38 pm
Location: Kissimmee, FL

Solved

Post 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 :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Good stuff :-)
Post Reply