php

Delete a file in PHP

<?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.

Was this helpful?