Question

What I am trying to do is delete up one level in a new folder in PHP.

I hear the function I want to use is 'unlink'. I'm not 100% whether I am using this correctly. The script I am editing is in /includes/scriptname.php, and im trying to get it to remove an image in: /images/products/example.jpg.

Would I be doing this correctly if I did this?

    unlink('../images/products/' . $filename);

or would this be incorrect? Any replies will be greatly appreciated.

Was it helpful?

Solution

../images/products/' . $filename is correct (Note that its '..' not '.'). As long as you refer to the parent directory with '..' you can operate on anything in there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top