如何使用codeigniter在数据库中上传视频文件

时间:2015-02-11 01:28:16

标签: codeigniter

我想在mysql数据库中上传视频文件

我的控制器编码

function add_videochk()
    {
        $this->load->helper('url');
        $this->load->library('session');    
        $this->load->model("add_db");
        $map=$_FILES['map']['name'];
        $filename=$this->input->post('map');
        if(is_uploaded_file($_FILES['map']['tmp_name'])) 
        {
            $filename = $_FILES['map']['name'];
            //$config['upload_path'] = './assets/video/';
            $config['upload_path'] = './uploads/';
            $config['allowed_types'] = 'mp4|3gp|gif|jpg|png|jpeg|pdf';
            $config['max_size']='';
            $config['max_width']='200000000';
            $config['max_height']='1000000000000';

            // $config['image_library']='gd2';
            $this->load->library('upload', $config);
            $img = $this->upload->do_upload('map');
        }
            $data["result"] = $this->add_db->addnewvideo($map);
            redirect('user/add_video','refresh');   
    }

当我上传图片文件时,它在数据库和uplaods文件夹中上传成功 但是当我上传视频文件时,它只上传数据库而不是文件夹

所以我想上传数据库中的视频文件及其文件夹

请帮忙......

1 个答案:

答案 0 :(得分:2)

首先检查帖子并上传文件大小

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M`

然后在config/mimes.php内添加您要上传的丢失文件类型,如下所示。

'mpeg'  =>  array('video/mpeg', 'video/quicktime'),
'mpg'   =>  array('video/mpeg', 'video/quicktime'),
'mp4'   =>  array('video/mp4', 'video/quicktime'),
'mpe'   =>  array('video/mpeg', 'video/quicktime'),
'qt'    =>  'video/quicktime',
'mov'   =>  array('video/quicktime', 'video/mp4'),
'avi'   =>  array('video/avi', 'video/x-msvideo'),