[eluser]macleodjb[/eluser]
I have this function which i am calling from my controller to delete files, but it's not allowing me to unlink the file and i'm not sure why.
This is the message i get.
Code:
Message: unlink() [function.unlink]: http does not allow unlinking
Here's my function
Code:
function delete_file_from_sys($id){
$owner_query = $this->db->query("SELECT * FROM `files` WHERE (`file_id` = '$id')");
$file = $owner_query->row_array();
$file_path = base_url(). $file['path'] . $file['file_name'];
if(unlink($file_path)){
return true;
} else {
return false;
}
}
and here's my controller function.
Code:
function delete_job_file(){
if(!isset($_SESSION['uid'])){
$this->session->set_flashdata('message','You must be logged in to delete files');
redirect('login/login');
}
$this->load->model('File_model');
$this->load->model('Edit_model');
$this->load->model('Main_model');
$file_id = $this->uri->segment(3);
if(empty($file_id)){
$this->session->set_flashdata('message','You must select a file to delete it');
redirect('edit/job_files');
}
if(!$this->File_model->check_file_owner($_SESSION['uid'], $file_id)){
$this->session->set_flashdata('message','It\'s not nice to try and delete other peoples files');
redirect('edit/job_files');
}
if($this->File_model->delete_file_from_sys($file_id) && $this->File_model->delete_file_from_sql($file_id)){
$this->session->set_flashdata('message','Your file has been deleted');
redirect('edit/job_files');
} else {
$this->session->set_flashdata('message','There was a problem deleting your file');
redirect('edit/job_files');
}
}//end of function