Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set the upload path for the Codeigniter upload library on a local machine?

Tags:

codeigniter

I have the following path set as the upload_path for Upload library included with Codeigniter.

 $this->upload_config['upload_path'] = './uploads/working/';

This path works fine on the remote server. However, when I'm debugging locally, it fails.

I have permissions set so the directory is writeable.

I added logging to the upload library and found that it is failing this check in the library:

! @is_dir($this->upload_path)

My development machine is a MacBook Pro running 10.6.2. I'm using MAMP Pro. My directory structure looks like:

app
cache
ci_1_7_2
html
 - css
 - images
 - index.php
 - js
 - uploads
   - large
   - normal
   - small
   - working

Any help would be greatly appreciated. Thanks for your time.

like image 826
someoneinomaha Avatar asked Apr 01 '10 20:04

someoneinomaha


2 Answers

When uploads folder is inside /application/ you can use:

$this->upload_config['upload_path'] = APPPATH . 'uploads/working/';

But for this structure, hardcode an absolute path or use:

$this->upload_config['upload_path'] = realpath(dirname(__FILE__)). '/uploads/working/';

Notice that APPPATH contains a trailing slash but realpath will strip the trailing slash.

like image 182
Phil Sturgeon Avatar answered Sep 28 '22 08:09

Phil Sturgeon


When all else fails, use absolute paths.

like image 28
stormdrain Avatar answered Sep 28 '22 08:09

stormdrain