Error formatting and filenotfound handling

This commit is contained in:
Andy Miller
2014-09-22 22:43:59 -06:00
parent 0b69ed4c7e
commit 7186082e65
4 changed files with 15 additions and 5 deletions

View File

@@ -198,10 +198,14 @@ class AdminController
if ($filename) {
$targetPath = $page->path().'/'.$filename;
if (file_exists($targetPath) && unlink($targetPath)) {
$this->admin->json_response = ['success', 'File deleted: '.$filename];
if (file_exists($targetPath)) {
if(unlink($targetPath)) {
$this->admin->json_response = ['success', 'File deleted: '.$filename];
} else {
$this->admin->json_response = ['error', 'File could not be deleted: '.$filename];
}
} else {
$this->admin->json_response = ['error', 'File could not be deleted: '.$filename];
$this->admin->json_response = ['error', 'File not found: '.$filename];
}
} else {
$this->admin->json_response = ['error', 'No file found'];