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 »