开发者

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

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
 - inde开发者_如何学运维x.php
 - js
 - uploads
   - large
   - normal
   - small
   - working

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


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.


When all else fails, use absolute paths.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜