|
上传图片都没问题,改成 PDF 提示:The filetype you are attempting to upload is not allowed.
PHP复制代码
function addFile ($id = null)
{
$this->load->library('upload');
$this->load->helper('date');
$config = array();
$upload_path = './upload/download/';
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png|pdf|doc|xsl';
$config['max_size'] = '10000';
// $config['max_width'] = '2048';
// $config['max_height'] = '1536';
// $config['encrypt_name'] = true;
$this->upload->initialize($config);
if ( ! $this->upload->do_upload())
{
$this->session->set_flashdata('info', img ('web/images/ico/disabled48.png').$this->upload->display_errors());
// echo ''.$this->upload->display_errors();
redirect ('admin/download/addFile/'.$id);
}
else
{
////////////////////////prepare insert to database///////////////////
$data = $this->upload->data();
$file_url = $data['raw_name'].$data['file_ext'];
/////////////////////////insert into database//////////
$this->session->set_flashdata('info', img ('web/images/ico/ok.png').'Picture upload successed:'.$file_url);
$temp = array(
'file_url '=>'upload/download/'.$data['orig_name'],
'file_name'=>$data['file_name'],
'file_type'=>$data['file_type'],
'file_size'=>$data['file_size'],
'file_name'=>$data['orig_name'],
'date_add' =>date("Y-m-d H:i:s"),
);
$this->db->where('id',$id);
$this->db->update('download',$temp);
redirect ('admin/download/show/'.$id);
}
}
复制代码
google 了一下 ,有人出现这问题:
http://codeigniter.com/forums/viewthread/70335/
可是没看懂。
还请大侠帮忙解决下。
HELP ING....... |
|