如何从数据库codeigniter中删除图像?

时间:2015-09-24 13:27:57

标签: php codeigniter

这是我的控制器:

public function doDelete($id_jeans)
{
    $where = array("id_jeans" => $id_jeans);
    $res = $this->admin_model->DeleteData('jeans', $where);
}

这是我的模特:

public function DeleteData($tabelname, $where)
    {
        if ($this->db->delete($tabelname, $where)) {
            redirect("admin/admin/index");
        }else {
            echo "tidak berhasil";
        }
        $res = $this->db->delete($tabelname, $where);
        return $res;            
    }

如何使用CodeIgniter删除图像?

1 个答案:

答案 0 :(得分:0)

您只是从表中删除数据。如果要从目录中删除文件:

public function DeleteData($tabelname, $where, $path_to_file)
{
    if ($res = $this->db->delete($tabelname, $where)) {
        unlink($path_to_file);
        redirect("admin/admin/index");
    }else {
        echo "tidak berhasil";
    }           
}