Deleting files

Hi there,

A project I’m working on at the moment requires me to delete files and folders on the server.

I’m testing it locally at the moment, and I’m running into a couple of problems.

Firstly, even though the subfolder and the files have their permissions set to 0777, I get the error message:

Warning: unlink(/Users/mickyginger/Sites/galleries/Cradles/index.php) [function.unlink]: Permission denied in /Users/mickyginger/Sites/includes/ on line 20

Secondly, and more worryingly, as I’m using a mac I have a hidden file .ds_store in every folder, which is created by mac os x, which also cannot be deleted, because of permission settings.

Can anyone shed some light on the best practice for the creation and deletion of files and folders with php.

Many thanks,

There aren’t any other files in the directory. Hmm, gimme a sec, I’ll run a test with some txt file or other.

this request isnt being called from /Users/mickyginger/Sites/galleries/Cradles/index.php is it? (Cant delete a file in use - which it will be if it’s open in anything…)

Nah, from /Users/mickyginger/Sites/admin/galleries/index.php

can you delete other files in that directory?

Nah, can’t delete anything. I placed a text file in the folder with permissions set to 0777, and I got the same error.

there may be a directory above the one in question with lower permissions.

Yeah, but I kinda want that in place. Like, I don’t want php to be able to delete important files. I thought that by setting up a subfolder with permissions set to 0777, I could put everything that I wanted php to delete in there, anything that’s essential for the site would sit above it protected by lower permissions.

Am I on the wrong lines here?