1

I have problem uploading the files, whenever i echo

$this->upload->display_errors();

this gives error The upload path does not appear to be valid.

my directory structure

- main
   - CI_Installation
   - uploads
     - brochures

The test i m doing is in my local machine. In production server the two inside folders will be in root folder instead of main folder.

I want to upload files to the uploads folder, i.e. outside CI installation folder. I have tried setting path ./uploads/brochures/ ../../uploads/brochures/ and every other possible path but still getting that error.

Edit

I know i have something wrong in path, folder permission would have yield another error. The error explicitly says The upload path does not appear to be valid.

Below is snippet of the code, posting whole controller is not feasible because it has several lines of code, which might be difficult to read.

                    $config['upload_path'] = './uploads/brochures/';
                $config['allowed_types'] = 'gif|jpg|png|pdf|docx|doc';
                $config['max_size'] = '10000';
                $config["remove_spaces"]=TRUE;
                $config['encrypt_name']  = TRUE;
                $this->load->library('upload',$config);
                $this->upload->initialize($config);
                $uploaded = $this->upload->do_upload("b_path");
                $data = array('upload_data' => $this->upload->data());

                echo "ERRORS = ".$this->upload->display_errors();

Can anybody help me here?

Thanks

5
  • 1
    I know that could be stupid but... how about the folder write permissions? Commented Oct 1, 2012 at 5:24
  • @manix, i m on windows in my local machine so folder permission would not be the issue here. Commented Oct 1, 2012 at 5:30
  • @JordanArseno, question updated, please see it Commented Oct 1, 2012 at 5:39
  • does the brochures directory exist? I ask because you said "my directory structure is"... but then didn't include it. Commented Oct 1, 2012 at 6:01
  • @JordanArseno, brochures directory is inside uploads directory and it exists Commented Oct 1, 2012 at 6:06

3 Answers 3

2

if you are on the localhost then you should change upload path to this

c:\wamp\www\ci_installation\upload\

And on the server if you set the path as you have done it will work ok. if have given you the path of your wamp installation if you are using something else then give the path according to your installation directory.

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

Comments

1

I have solved the problem myself. I set the constant UPLOAD_PATH in constants.php

define('UPLOAD_PATH',dirname(dirname(dirname(dirname(__FILE__)))).DIRECTORY_SEPARATOR.'uploads/');

Comments

0

You can use FCPATH constant then use '../' to go one directory up until you reach the desired folder.

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.