我在使用codeigniter上传库上传图片时遇到问题,我不断收到错误,
The upload path does not appear to be valid.
我正在尝试上传的文件路径如下,
$config [‘upload_path’] =’./ media / images / site’;
当我点到下面的时候,
die(var_dump(is_dir($config['upload_path'])));
我得到以下退回,
bool(true)
该文件夹也是可写的(777),所以我不确定我哪里出错了,下面是我的上传代码,
$config['upload_path'] = './media/images/site';
//die(realpath($config['upload_path']));
//die(var_dump(is_dir($config['upload_path'])));
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '1500';
$config['max_width'] = '390';
$config['max_height'] = '269';
$this->load->library('upload',$config);
if ( ! $this->upload->do_upload() && $_FILES['userfile']['error'] != 4)
{
$data['error'] = $this->upload->display_errors();
$this->template->build('/admin/pages/about_us', $data);
}
else
{
$image = $this->upload->data();
if(empty($image['file_name'])) {
$image['file_name'] = $this->formbuilder->defaults['page_image'];
}
$page = array(
//'page_title' => $this->input->post('page_title'),
//'page_slug' => $this->input->post('page_slug'),
'page_content' => $this->input->post('page_content'),
'page_image' => $image['file_name'],
'date_created' => date("Y-m-d h:i:s"),
'created_by' => 1
);
if($this->pages_model->insert($this->security->xss_clean($page)))
{
redirect('/admin/dashboard');
}
}
我看不到任何明显会阻止文件上传的内容,下面是我项目的文件夹结构
/application
/system
index.php
.htaccess
/media
/images
/site
/admin
/css
/js
如果有人能够解决我的问题,那就太好了.
编辑PETULENT DOWNVOTER
会导致这个问题的原因是什么?
(有一个问题,好像它不是很明显)