Having problems to store a video to server. I had changed all possible types in mimes.php, but the issue remains same here is my code.
Controller
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();
}
}
$data['title'] = $this->input->post('title');
$data['video_url'] = $this->input->post('video_url');
$this->load->model('AdminModel');
$this->AdminModel->saveGallery($data);
}
}
$data['sidebar'] = $this->load->view('admin/sidebar', NULL, TRUE);
$this->load->view('admin/header');
$this->load->view('admin/frontslideradd', $data);
$this->load->view('admin/footer');
}
Model
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);
}
View-add
<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>
mimes
'3gp' => array('video/3gp', 'video/3gpp'),
'mp4' => 'video/mp4',
It gives no error but successfully passes other data to server except only video Please rectify, thanx in advance
2
Answers