Deleting a file

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
binjured
Forum Newbie
Posts: 7
Joined: Fri May 14, 2004 6:07 pm

Deleting a file

Post by binjured »

Maybe I am missing something simple here, but unlink($file) isn't working for deleting files. Where do a specify a directory here? This is for an upload script... people can upload files to a dir, it puts the file name into a mysql DB, they can then delete the file. It properly removes the respective name from the mysql DB when doing this, but how can the actual FILE be deleted? I'm sure i'm missing something simple. Thanks.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

unlink('/the/full/path/to/'.$filename);
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

one thing you may want to make sure is that after coping te file after upload, use chmod(filepath, 0777); on the file (if its on linux server), if you dont, you wont be able to delete it :).
Post Reply