Search code examples
phpdirectoryunlink

How to remove file from a diffrent directory with PHP?


I have a PHP file with unlink() in application/views/delete/target.php and I want to delete a file in application/views/uploads/target.jpg. When I call target.php I want to remove both target.php and target.jpg but so far I was only able to remove the target in the delete/ folder.

<?php function destruct()
            { 
                unlink('../views/uploads/target.jpg');
                unlink('target.php');
            }
            destruct(); ?>

Solution

  • <?php function destruct()
                { 
                    unlink('../uploads/4d.jpg');
                    unlink('4d.php');
                }
                destruct(); ?>
    

    I just needed to go down by one folder and enter next one.