PHP Tips & Tutorials

PHP: Delete File / Erase File / Remove File

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.

By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Shoot me a message.