2010-04-01 53 views
5

我将以下路径设置为Codeigniter附带的上传库的upload_path。如何在本地机器上设置Codeigniter上传库的上传路径?

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

此路径在远程服务器上正常工作。但是,当我在本地调试时,它失败。

我有权限设置,因此目录是可写的。

我添加记录到上传库,发现它是在库没有这个检查:

! @is_dir($this->upload_path) 

我的开发机是一个的MacBook Pro运行10.6.2。我正在使用MAMP Pro。我的目录结构如下:

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

任何帮助将不胜感激。谢谢你的时间。

回答

9

当上传文件夹里面/应用/你可以使用:

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

但对于这种结构,硬编码的绝对路径或使用:

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

注意APPPATH要包含一个斜线,但实时路径将剥离尾部斜线。

3

当所有其他情况都失败时,使用绝对路径。