Php Code To Remve File From A Folder Using Php
In this Php Tutorial we will see How To Delete File From A Folder Using Php .
I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .
Php Source Code:
<?php
if(isset($_POST['remve_file']))
{
    $file_Path = $_POST['fileToRemove'];
    // check if the file exist
    if(file_exists($file_Path))
    {
        unlink($file_Path);
        echo 'File Deleted';
    }else{
        echo 'File Not Exist';
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>PHP DELETE FILE FROM FOLDER</title>
    </head>
    <body>
        <form action="php_delete_file_from_folder.php" method="post">
            File Path: <input type="text" name="fileToRemove"><br><br>
            <input type="submit" name="remve_file" value="Delete File">
        </form>
    </body>
</html>

3 comments
commentsThank you so much
ReplyIsnt this missing the file php_delete_from_folder.php?
Replyit's the current file name
Reply