public function Delete($files, \Slim\Slim &$app, $page) { $obj = new Files(); $obj->parseFile($files); $user_id = $obj->user_id; //$cookieDB = $obj->cookie; $cookie = $app->getCookie('username'); $db = $app->db; $logged = new Logged(); $id = $logged->getLogged($db, $cookie); //checking of the user is registered in Users table as the user or anonymous which added this file and getting his id if ($id == $user_id) { $foo = new Foo(); $foo->token = $page; $mapper = new FooMapper($db); $files = $mapper->delete($foo); $path = $obj->path; $filename = "uploads/" . $path; //deleting file from the folder unlink($filename); $app->redirect('/TwigBlog/'); } else { $app->error(); } }