求救:CI上传PDF问题。
上传图片都没问题,改成 PDF 提示:The filetype you are attempting to upload is not allowed.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....... 急救: 问题严重了。RAR 也不能上传…… ZIP可以。救命!!! 我看了那个官方论坛的链接,发现和你的代码没有什么不一样呀。 完了。。。。可能是人品问题了。。。。。
老大,你那边 上传 PDF 、RAR 都正常吗? 我没写过这样的功能。呵呵,不知道~~看看别人~ 也许是其它配置的问题? application/config/mimes.php
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types.It is used by the
| Upload class to help identify allowed file types.
|
*/
[ 本帖最后由 aligo 于 2008-3-20 16:42 编辑 ] 不知道啥情况,PDF 可以了。(我也没修改什么,估计天气变暖了,嘿嘿。)
对于一些不能上传的类型,确实是修改 mimes.php
比如 上传 .flv
'flv' => array('video/x-flv', 'flv-application/octet-stream', 'application/octet-stream'),
但是 RAR的还是不好用,各位有没有上传RAR的mimes? 'rar' => array('application/x-rar-compressed', 'application/octet-stream')
页:
[1]