My delete function does not delete the targeted file
Posted
by Chester Sabado
on Stack Overflow
See other posts from Stack Overflow
or by Chester Sabado
Published on 2010-03-13T10:24:56Z
Indexed on
2010/03/13
10:35 UTC
Read the original article
Hit count: 735
codeigniter
|php
Basically I could upload files based on a project. Whenever I create a project, a new directory is created with the directory name as the project_name e.g. this is a test -> this-is-a-test. But my problem is I couldn't delete a file in a directory.
function delete_image($id)
{
$this->load->model(array('work_model', 'project_model'));
$result = $this->work_model->get_work($id);
$result = $this->project_model->get_project($result->project_id);
$dir = str_replace(" ", "-", $result->project_name);
$result = $this->work_model->delete($id);
if (isset($result)){
unlink('./uploads/' . $dir . '/' . $result->full_path);
}
redirect('admin/project/view_project/' . $result->project_id);
}
Need help on this thanks.
© Stack Overflow or respective owner