0

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.

2
  • what is the path of the folder uploads is in project root?. At the end of the path you need to use / like $config['upload_path'] = "uploads/"; Commented Mar 23, 2018 at 19:15
  • Try just $config['upload_path'] = './uploads/'; Make sure you have correct folder permissions. Commented Mar 23, 2018 at 20:42

2 Answers 2

3
$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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.