1

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(); ?>
6
  • You need to go down one more directory, like this: unlink('../../views/uploads/target.jpg');, assuming you have permission to delete the file. Commented Dec 16, 2017 at 15:37
  • ../ is for one directorey so i always need to go one by one to the one that has the connection to the wanted one Commented Dec 16, 2017 at 15:39
  • Yes, I see that you could keep it simpler, like this: unlink('../uploads/target.jpg'); Commented Dec 16, 2017 at 15:41
  • still thanks for help i'm more of a noobie with php Commented Dec 16, 2017 at 15:43
  • I'm confused. You want target.php to delete itself? Commented Dec 16, 2017 at 16:38

1 Answer 1

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.