PHP: Delete File / Erase File / Remove File

by Yang Yang on April 22, 2009

in PHP Tips & Tutorials

As long as the owner of the php script has the necessary privilege to delete a file, the php script has the ability to delete it.

To delete a file with PHP, use the unlink() function:

unlink('tmpfile.txt') or die('Unable to delete the file');

It returns true if the deletion is successful and false otherwise.

Related Posts

Leave a Comment

Previous post:

Next post: