Page 1 of 1

deleting files

Posted: Thu Nov 30, 2006 12:22 pm
by konstandinos
i've read up on deleting files, and it seems that unlink($filename), where $filename is just a string containing the file url, is what i must use.

but i've also read that unlink merely unlinks the file from its directory, thus it isn't actually removed, but only forgotten about.

now if my hosting provider charges me per megabyte of storage used, and i unlink a 50mb file, is it deleted or merely just forgotten about?

when i do a directory listing (using glob() for example) the file is no longer there, but i want to be sure that it's not taking up space (and hence costing me money) either.

can someone please confirm this or perhaps explain how files are to be properly removed in php?

thanks

Posted: Thu Nov 30, 2006 12:24 pm
by Luke
Files are never DELETED per se on a system anyway... when you delete a file in windows, the only thing you are "erasing" is its address... the only way to really "erase" anything is to write over it. (with either real data or just all zeros)

Posted: Thu Nov 30, 2006 12:40 pm
by konstandinos
ok so is it safe to say that if my file is unlinked, it no longer takes up space? i am referring to checking free space on a hard drive. i understand that it isn't physically removed, and is thus still occupying space. but as far as my os goes, that space is now free.

correct?

Posted: Thu Nov 30, 2006 1:02 pm
by Luke
Somebody correct me if I'm wrong, but I am pretty sure that once unlinked, that space is free to use.

Posted: Thu Nov 30, 2006 1:13 pm
by John Cartwright
The Ninja Space Goat wrote:Somebody correct me if I'm wrong, but I am pretty sure that once unlinked, that space is free to use.
yup.