上传文件||您尝试上传的文件类型不允许

将视频存储到服务器时遇到问题。我已经更改了 mimes.php 中所有可能的类型,但问题仍然存在,这是我的代码。 控制器


    public function frontsliderAdd()

{

    if ($this->session->userdata('admin_logged_in') != TRUE) {

        redirect(base_url() . 'admin/login');

    }

    $data['active'] = 'frontslider';

    if (isset($_POST['addgallery'])) {

        $this->form_validation->set_rules('title', 'Banner Title', 'trim|required');

        $this->form_validation->set_rules('video_url', 'Video Link', 'trim|required');


        if ($_FILES["video_upload"]['name'] == '') {

            $this->form_validation->set_rules('image_upload', 'Image', 'required');

        }


        if ($this->form_validation->run() == TRUE) {

            if ($_FILES["video_upload"]['name']) {


                $config['upload_path'] = './public/uploads/banner_images';


                $config['allowed_types'] = 'jpg|png|jpeg|gif|mp4|avi|mov';


                //$this->load->library('upload', $config);

                $config['max_size'] = '0';

                $this->load->library('upload', $config);

                if (!$this->upload->do_upload('video_upload')) {

                    $error_msg = $this->upload->display_errors();

                } else {

                    $data['video'] = $this->upload->data();

                }

            }

模型


    public function saveGallery($data)

{

    $array = array(

        'title' => $data['title'],

        'video' => $data['video']['file_name'],

        'video_url' => $data['video_url']

    );

    $this->db->insert('front_slider', $array);

}

查看-添加


 <div class="form-group">

                                        <label for="image_upload">Upload Video</label>

                                        <input type="file" class="form-control" id="video_upload" name="video_upload">

                                        <span class="help-block" style="color: red;"><?php echo form_error('video_upload') ?></span>

                                    </div>

哑剧


'3gp'   =>  array('video/3gp', 'video/3gpp'),

'mp4'   =>  'video/mp4',

它没有给出错误,但成功地将其他数据传递给服务器,除了只有视频请纠正,thanx提前


长风秋雁
浏览 299回答 2
2回答

慕妹3242003

文件上传发生错误时停止以获取确切的错误&nbsp;if (!$this->upload->do_upload('video_upload')) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$error_msg = $this->upload->display_errors(); // Make exit here&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print_r($error_msg);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['video'] = $this->upload->data();&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['title'] = $this->input->post('title');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data['video_url'] = $this->input->post('video_url');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$this->load->model('AdminModel');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$this->AdminModel->saveGallery($data)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }

潇湘沐

您将上传数据存储在$data['image']&nbsp;=&nbsp;$this->upload->data();并分配了错误的键&nbsp;'video'&nbsp;=>&nbsp;$data['video']['file_name']&nbsp;//&nbsp;Here&nbsp;is&nbsp;your&nbsp;problem您应该如下更改您的密钥'video'&nbsp;=>&nbsp;$data['image']['file_name']希望这可以帮助
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript