Book HomePHP CookbookSearch this book

19.6. Deleting a File

19.6.1. Problem

You want to delete a file.

19.6.2. Solution

Use unlink( ):

unlink($file) or die ("can't delete $file: $php_errormsg");

19.6.3. Discussion

The function unlink( ) is only able to delete files that the user of the PHP process is able to delete. If you're having trouble getting unlink( ) to work, check the permissions on the file and how you're running PHP.

19.6.4. See Also

Documentation on unlink( ) at http://www.php.net/unlink.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.