deleting files

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
konstandinos
Forum Commoner
Posts: 68
Joined: Wed Oct 04, 2006 4:20 am

deleting files

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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)
konstandinos
Forum Commoner
Posts: 68
Joined: Wed Oct 04, 2006 4:20 am

Post 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?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Somebody correct me if I'm wrong, but I am pretty sure that once unlinked, that space is free to use.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Post Reply