0

I'm new to PHP. I want to delete a file from a folder in the parent of my path. I tried to do this with 'unlink' but failed.

How can I delete the '1.mp3' file in the admin/Records/mp3 folder while working on the index.php page, as in the image below.

folders

3
  • Please provide enough code so others can better understand or reproduce the problem. Commented Apr 22, 2022 at 23:50
  • You are missing some context here. I assume you are in a web page, running inside a web server like Apache, so it would be good to add that to your question. Commented Apr 22, 2022 at 23:57
  • It looks like your index.php is at the root of your project, so you could just do $projectRoot = realpath(__DIR__); to get the full pathname of the root, and then add the rest of the directories + filename to that. Commented Apr 22, 2022 at 23:58

1 Answer 1

1

Code:

unlink('../admin/Records/mp3/1.mp3');
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.