【发布时间】:2016-12-06 23:01:54
【问题描述】:
这个问题已经问了很多,但是在尝试了很多事情之后,我仍然找不到解决这个问题的原因。
我正在自动加载上传库。
我的文件夹结构是:
/application/
/assets/
css/
images/
hero/
js/
/system/
我的控制器:
$fileName = $this->input->post('title') . '_hero';
$filePath = './assets/images/hero/';
$config['allowed_types'] = 'gif|jpg|png';
$config['overwrite'] = true;
$this->upload->initialize($config);
if (!empty($_FILES['heroimage'])) {
$config['file_name'] = $fileName;
$config['upload_path'] = $filePath;
if (!$this->upload->do_upload('heroimage')) {
$error = array('error' => $this->upload->display_errors());
var_dump($error);
} else {
$data = array('upload_data' => $this->upload->data());
var_dump($data);
}
}
我已经尝试过初始化它现在的状态和使用$this->load->library('upload', $config);,但都没有成功。
我还检查了目录是否存在以及它是否可写并且都返回了 true。
我尝试的另一件事是将上传路径设置为$config['upload_path'] = FCPATH.'assets\images\hero';
任何能指引我正确方向的帮助将不胜感激。
【问题讨论】:
标签: php codeigniter