Delete image when deleting article
这个提交包含在:
父节点
3b50449d56
当前提交
517d4cdf4a
共有 1 个文件被更改,包括 13 次插入 和 0 次删除
|
@ -81,6 +81,17 @@ class PostHandler
|
|||
return json_encode($this->filesData)."id: ".$this->data;
|
||||
}
|
||||
|
||||
private function remove_image() {
|
||||
$uploadPath = $this->uploadBaseDir.$this->data["id"].".jpg";
|
||||
if (file_exists($uploadPath) && unlink($uploadPath)) {
|
||||
$this->responseArray["message"] = "Success: Deleted image";
|
||||
} else if (!file_exists($uploadPath)) {
|
||||
$this->responseArray["message"] = "Success: No image to delete";
|
||||
} else {
|
||||
$this->responseArray["message"] = "Success: Could not delete image";
|
||||
}
|
||||
}
|
||||
|
||||
function create()
|
||||
{
|
||||
$result = -1;
|
||||
|
@ -114,6 +125,8 @@ class PostHandler
|
|||
$result = -1;
|
||||
if ($this->type == "article") {
|
||||
$result = $this->dao->remove_article($this->data);
|
||||
if ($result != 0)
|
||||
$this->remove_image();
|
||||
} else if ($this->type == "category") {
|
||||
$result = $this->dao->remove_category($this->data);
|
||||
} else
|
||||
|
|
正在加载…
在新工单中引用