Nikhil P
Nikhil P

Reputation: 15

Codeigniter deleting files in a directory not working

I am trying to delete pdf files from a folder. I have written the delete_files function as follows

public function delete_files($company_id)
    {
        $this->load->model('search_model');

        $company = $this->search_model->get_company($company_id);
        $username  = $company[0]['username'];
    $path=$this->config->base_url('/uploads/'.$username . '/' . 'uploaded');
    $this->load->helper("file"); // load the helper
    delete_files($path, true); // delete all files/folders
    }

when i did echo $path; it shows the right path where i want the files deleted but when i run the entire function nothing happens and i just get a white screen.

Upvotes: 1

Views: 455

Answers (2)

Divyesh
Divyesh

Reputation: 389

try this code

Use

$path = FCPATH . "uploads/$username/uploaded";
unset($path);

Upvotes: 0

Tpojka
Tpojka

Reputation: 7111

You need to use path to file and not resource locator.

$path = FCPATH . "uploads/$username/uploaded";

Upvotes: 1

Related Questions