我正在使用 Code Igniter 框架中的上传库创建一些文件上传功能,但我遇到了一个问题,我不断收到错误消息,指出我的文件上传路径不正确。我检查了很多次,文件结构没有问题,文件肯定存在。
这是我的模型上传代码(我很想检查我在这个过程中的位置):
class Gallery_model extends CI_Model {
var $gallery_path;
function __construct() {
parent::__construct();
$this->gallery_path = realpath(APPPATH . '../images/profileImages');
//$this->gallery_path = realpath($this->config->base_url() . 'images/profileImages');
}
public function doUpload() {
$config = array(
'allowed_types' => 'jpg|jpeg|png|gif',
'upload_path' => $this->gallery_path
);
$this->load->library('upload', $config);
if($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
die(print_R($data));
} else {
$error = array('error' => $this->upload->display_errors());
die(print_R($error));
}
}
}
我的图像文件夹位于应用程序之外,称为“图像”,其中包含一个名为“profileImage”的文件夹,我希望在其中保存这些文件。我收到以下错误:
“上传路径似乎无效。”
我一生都无法弄清楚为什么这条路确实存在时行不通。有没有人有任何想法?谢谢