/** * Deletes a file * * @return void */ public function deletefileTask() { // Check for request forgeries Request::checkToken('get'); // Check if they're logged in if (User::isGuest()) { $this->displayTask(); return; } // Incoming file $file = trim(Request::getVar('file', '', 'get')); if (!$file) { $this->setError(Lang::txt('COM_BLOG_NO_FILE')); $this->displayTask(); return; } // Incoming $archive = new Archive(Request::getWord('scope', 'site'), Request::getInt('id', 0)); // Build the file path $path = $archive->filespace(); if (!file_exists($path . DS . $file) or !$file) { $this->setError(Lang::txt('COM_BLOG_FILE_NOT_FOUND')); $this->displayTask(); return; } // Attempt to delete the file if (!Filesystem::delete($path . DS . $file)) { $this->setError(Lang::txt('COM_BLOG_UNABLE_TO_DELETE_FILE')); } // Push through to the media view $this->displayTask(); }