,我用form_open_multipart()
,我有:上传文件图像使用CI
<input type="file" name="user_photo" style="margin-top: 5px;" />
我有这样的配置,我的控制器是这样的:
$config['upload_path'] = './resources/uploads/';
$config['allowed_types'] = 'jpg|gif|png|bmp|jpeg';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->load->library('upload', $config);
if(!$this->upload->do_upload('user_photo')) {
echo $this->upload->display_errors('<p>', '</p>');
} else {
echo "<pre>"; print_r($this->upload->data());
}
但是,当我尝试上传图像文件与文件类型* .jpg,我有这样的错误:The file type you are attempting to upload is not allowed.
有没有我的配置有任何问题,。? 谢谢。
您正在使用哪个版本的CodeIgniter,以及哪个版本的PHP是您遇到使用问题的Web服务器? – stealthyninja 2012-01-04 10:30:44
是否在你的配置中使用:$ config ['file_name'] ..? – 2012-01-04 10:57:25
@stealthyninja我使用CodeIgniter 2.1.0和PHP 5.3.0 ,. – Praditha 2012-01-04 15:57:33