DEV
DEV

Reputation: 667

CodeIgniter: The upload path does not appear to be valid

I am getting this error in the upload functionality for CodeIgniter Image upload.

The upload path does not appear to be valid

This problem started happening after I uploaded the site from my local system to my live system.

I am adding my code below. I don't know what is wrong. I have gone through all the other forums on this. But nothing helped.

    $config['upload_path'] = 'uploads';
    $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
    $this->load->library('upload',$config);     
    $this->upload->initialize($config);

The folder has full permissions, and as I said it was working on my local system. Not sure what the issue could be. Any help will be greatly appreciated.

Upvotes: 0

Views: 4863

Answers (2)

Kopi Bryant
Kopi Bryant

Reputation: 1366

Always try to debug your upload_path. I have the same case and I solved it. The problem is the path whether your path has been set correctly or not.

In my case:

$config = array(
  'upload_path' => FCPATH."application/upload",
  'allowed_types' => "gif|jpg|png|jpeg|pdf",
);

The FCPATH is the your project file path. Hope this would help others.

Upvotes: 0

Alex
Alex

Reputation: 9265

$config['upload_path'] = 'uploads';

upload path directory must be writable and the path can be absolute or relative. If your uploads folder is in your document root then ./uploads/ should work or FCPATH . 'uploads/' (check if FCPATH has a trailing slash, if not add it to uploads).

Aside from that the path has to exist, CodeIgniter won't make the directory for you.

Upvotes: 3

Related Questions