mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-12-27 02:40:48 +01:00
Added delete task
This commit is contained in:
@@ -179,14 +179,34 @@ class AdminController
|
||||
move_uploaded_file($tempFile,$targetFile);
|
||||
$this->admin->json_response = ['success', 'File uploaded successfully'];
|
||||
} else {
|
||||
$this->admin->json_response = ['error', 'No files found'];
|
||||
$this->admin->json_response = ['error', 'No file found'];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
protected function taskDelmedia()
|
||||
{
|
||||
$page = $this->admin->page(true);
|
||||
$uri = $this->grav['uri'];
|
||||
|
||||
if (!$page) {
|
||||
$this->admin->json_response = ['error', 'No Page found'];
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = !empty($this->post['filename']) ? $this->post['filename'] : null;
|
||||
if ($filename) {
|
||||
$targetPath = $page->path().'/'.$filename;
|
||||
|
||||
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', 'No file found'];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user