Php : How To Delete File From Directory Using Php

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>


php delete file


                     




Share this

Related Posts

Previous
Next Post »

3 comments

comments
Anonyme
11 novembre 2018 à 01:28 delete

Thank you so much

Reply
avatar
28 mai 2020 à 13:55 delete

Isnt this missing the file php_delete_from_folder.php?

Reply
avatar