Search code snippets, questions, articles...

Delete a file in PHP

    $filePath = 'path/to/file';
    unlink($filePath); //THIS FUNCTION DELETES THE FILE

To delete a file in PHP, you can use the inbuilt PHP function unlink($file). It requires a file path as its required parameter. This function will delete the file if found in the given location.

Search Index Data (The code snippet can also be found with below search text)

unlink() | PHP
Was this helpful?
Programming Feeds
Learn something new everyday on Devsheet