Reputation: 25
public function deleteAllEmailRelatedFolders($clientID) {
$path = getcwd();
//Delete Email Inbox Attachments
$dir = $path . "\cdn\data\inbox/$clientID";
//Delete Email Sent Attachments
$dir2 = $path . "\cdn\data\sent/$clientID";
var_dump($dir);
var_dump($dir2);
$this->rrmdir($dir);
$this->rrmdir($dir2);
}
protected function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir . "/" . $object) == "dir")
$this->rrmdir($dir . "/" . $object);
else
unlink($dir . "/" . $object);
}
}
reset($objects);
rmdir($dir);
}
}
When i try to rmdir run on my linux.It does not works correctly.when i run it WAMP server in my localhost.It works perfectly.Please help me to solve this issue
Upvotes: 0
Views: 362
Reputation: 875
As pointed out by shatheesh in a comment, your paths are incorrectly formatted for Linux.
Change your paths to:
//Delete Email Inbox Attachments
$dir = $path . "/cdn/data/inbox/$clientID";
//Delete Email Sent Attachments
$dir2 = $path . "/cdn/data/sent/$clientID";
More information about Linux directory paths and what they do is available at http://www.tecmint.com/linux-directory-structure-and-important-files-paths-explained/
Upvotes: 2