php – codeigniter视频上传

我正在尝试上传视频.

我的mime配置:

'wmv' => array('video/wmv', 'video/x-ms-wmv', 'flv-application/octet-stream', 'application/octet-stream'),
'flv' => array('video/x-flv', 'flv-application/octet-stream', 'application/octet-stream'),
'mp4' => 'video/mp4',
'3gp' => 'video/3gpp'

我的看法:

 <div id="upload">
        <?php
        echo form_open_multipart('audio');
        echo form_upload('userfile');
        echo form_submit('upload','Upload');
        echo form_close();
        ?>
</div>

我的控制器:

 function index() {
    $this->load->model('Audio_model');
    if ($this->input->post('upload')) {
        $this->Audio_model->do_upload();
    }
    $this->load->view('v_audio');
}  

我的模特:

 function do_upload() {
    $config = array(
        'allowed_types' =>  'mp4|3gp|flv|mp3',
        'max_size'=>'100000',
        'upload_path' => $this->gallery_path
    );
    $this->load->library('upload', $config);
    if ($this->upload->do_upload()) {
        echo "Upload success!";
    } else {
        echo "Upload failed!";
    }
}  

我可以成功上传mp3,但不能上传mp4,3gp或者flv,它们都无法上传.

最佳答案 在config / mimes.php中添加mime类型

'flv'    => array('video/x-flv', 'flv-application/octet-stream', 'application/octet-stream'),
'mp4' => 'video/mp4',
'3gp' => 'video/3gpp'  

并在根文件夹中使视频文件夹足够…..

点赞