Reputation: 65
I am doing a page where the user can delete the file he uploaded. And i am trying to delete it , but it doesn't seem to work.
First I am creating the directory that will contain the files.
And i am creating it like this :
mkdir($filepath , 0777 , true);
The part with creating the file works just perfect. Back to the delete page , I am trying to do it like this :
unlink("PROOT . 'files' . DS . $dir . DS . $settings->name");
And the PROOT
is the root of the file , as i am doing object oriented programming and i am doing it from security reasons , and also the DS
is the separator.
A vardump
of the parameter from link would look like this /framework/files/4/peep(2).jpg
and the link of the file looks like this http://localhost/framework/files/4/peep(2).jpg
and i am 100% sure that there is not a a problem with the PROOT
or the DS
.
Upvotes: 0
Views: 71
Reputation: 780724
There are two problems.
First, you have quotes around the concatenation, which is making everything literal except for $dir
and $settings->name
.
Second, the variable you should use for the root is $_SERVER['DOCUMENT_ROOT']
, not PROOT
.
So it should be:
unlink($_SERVER['DOCUMENT_ROOT'] . 'files' . DS . $dir . DS . $settings->name);
Upvotes: 1