为什么我的上传路径无效? (Codeigniter-图书馆) [英] Why is my upload path invalid? (Codeigniter-Library)
问题描述
我正在创建一个库,并将其作为项目的一部分,其中一种方法是包装上传助手。
I'm creating a library as part of a project and one of the methods is a wrapper for the upload helper.
方法:
public function upload(){
echo "Doing upload";
$config['upload_path']= RESOURCE_PATH . "Downloads";
$config['allowed_types']='pdf|doc';
$config['max_size']='10000';
//echo $config['upload_path'];
$this->CI->load->library('upload',$config);
if(!$this->CI->upload->do_upload()){
echo "Couldn't do the upload";
echo $this->CI->upload->display_errors();
echo $config['upload_path'];
}
else{
echo "Could do the upload";
}
}
我已经检查了Downloads文件夹的目录权限并且它存在,但是出现以下错误:上传路径似乎无效。
I've checked the directory permissions of the Downloads folder and that it exists but I'm getting the following error: "The upload path does not appear to be valid."
我该如何解决这个问题?
How do I resolve this issue?
编辑::我创建了一个符号链接,因此目录strucutre的确像这样:
www -> /home/user/Dropbox/www/appname
关于所用变量的说明:
$this->CI = &get_instance(); // Defined in custom library class
define('RESOURCE_PATH', APPPATH . 'views/resources/'); // Defined in constants.php
推荐答案
找出了一个愚蠢的问题。
Figured out the idiotic problem.
我正在自动加载库,并且在我尝试
时如何通过$ this-> load初始化配置->库('upload',
$ config);
I was autoloading the library and some how when I was trying to initialize the configuration by $this->load->library('upload', $config); it wouldn't do so.
相反,我将配置文件放在config / upload.php
Instead I put my config files in config/upload.php
这样做的另一种方法是
$ this-> upload-> initialize($ config);
The other method to do so would have been $this->upload->initialize($config);
这篇关于为什么我的上传路径无效? (Codeigniter-图书馆)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!