将视频存储到服务器时遇到问题。我已经更改了 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提前
2 回答
慕妹3242003
TA贡献1824条经验 获得超6个赞
文件上传发生错误时停止以获取确切的错误
if (!$this->upload->do_upload('video_upload')) {
$error_msg = $this->upload->display_errors(); // Make exit here
print_r($error_msg);
exit;
} else {
$data['video'] = $this->upload->data();
$data['title'] = $this->input->post('title');
$data['video_url'] = $this->input->post('video_url');
$this->load->model('AdminModel');
$this->AdminModel->saveGallery($data)
}
潇湘沐
TA贡献1816条经验 获得超6个赞
您将上传数据存储在
$data['image'] = $this->upload->data();
并分配了错误的键
'video' => $data['video']['file_name'] // Here is your problem
您应该如下更改您的密钥
'video' => $data['image']['file_name']
希望这可以帮助
添加回答
举报
0/150
提交
取消