【发布时间】:2016-05-15 11:10:53
【问题描述】:
function do_upload(){//This is my controller//
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['overwrite'] = true;
//$config['max_size'] = '100';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$this->load->library('upload');
$this->upload->initialize($config);
$this->upload->do_upload();
if (!$this->upload->do_upload()){//I also found out that this is the part that is not working
echo "failed!";
}
else{
$this->upload->data();
echo "success!";
}
}
“我已经尝试了一些教程来完成这项工作,但似乎对这个没有任何帮助”
【问题讨论】:
-
检查您的表单 enctype 属性是否设置。 w3schools.com/tags/att_form_enctype.asp
-
我已经检查过了,这是我的表单代码
-
你是否收到了失败的消息然后试试这个 print_r( $this->upload->display_errors());您也可以将文件上传字段名称作为参数传递给 do_upoad('userfile') 方法。示例 userfile 是表单字段名称
-
这是错误消息先生“上传目标文件夹似乎不可写。”
-
如果您在应用程序之外有文件夹,请在此处为前端控制器路径提供 FCPATH 的完整路径
FCPATH.'uploads/'像这样更改它
标签: file codeigniter file-upload