如何在本地计算机上设置Codeigniter上传库的上传路径? [英] How do you set the upload path for the Codeigniter upload library on a local machine?

查看:80
本文介绍了如何在本地计算机上设置Codeigniter上传库的上传路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将以下路径设置为Codeigniter包含的上传库的upload_path。

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)

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

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.

推荐答案

当上传文件夹在/ application /内时,您可以使用:

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/';

请注意,APPPATH包含一个尾部斜杠,而realpath将剥离尾部斜杠。

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

这篇关于如何在本地计算机上设置Codeigniter上传库的上传路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆