sangee
sangee

Reputation: 77

delete directory in codeigniter

iam doing my project in codeigniter in that i used to create new directory to upload my images.now i need to delete my new directory for that i have tired this coding,

 $dir = '/var/www/uploads/chat/'.$input['chat_id'];
   system('/bin/rm -rf ' . escapeshellarg($dir));

but its not working for me.i have got this coding from this link http://stackoverflow.com/questions/1296681/php-simplest-way-to-delete-a-folder-including-its-contents what i need to do?

Upvotes: 0

Views: 3252

Answers (1)

ABorty
ABorty

Reputation: 2522

when you are creating the directory use 777 as permission like

mkdir('new_dir', 0777, true);

and then try the below code

if(rmdir('new_dir'))
{
    echo "deleted";die;   
}
else
{
    echo "not deleted";die;
}

i checked it and found,if your folder has not right permission then it will not be deleted.

please try and let me know the status.

Upvotes: 3

Related Questions