为什么我用CI的upload上传文件,总是显示error
CONTROLLER代码如下function add_bg()
{
$this->_check_status();//检测用户登陆状态
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_height']= '360';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
}
form的代码如下:
<form id="bg_form" action="http://localhost/index.php/administrator/add_bg" method="post" enctype="multipart/form-data" >
<span class="grey">说明:上传文件高度为390px,图片格式为jpg,gif,png</span><br />
<input type="file" name="mainbg" class="file_input" />
<input type="button" value="上传" class="form_btn" id="submit_bg" />
</form>
现在我选择了文件,上传后却显示:
You did not select a file to upload.
这是为什么啊?是哪里还要设置吗? if ( ! $this->upload->do_upload())
改成
if ( ! $this->upload->do_upload('mainbg')) Hex 发表于 2011-5-11 17:28 static/image/common/back.gif
改成
感觉文档里这部分也是没有指明
弄得我以前用ci这个上传类半天没弄懂.
文档里没有指明type=file的name..... 你看一下 框架的upload就明白了 回复 zhouli520 的帖子
文档里明确说了,只不过你没看到而已。
还是那句话,看手册要仔细。
页:
[1]