John Davidson

php - Can't Upload Video Codeigniter

0 comments
Message:


I tried to upload a video using codeigniter 3. but why I got an error "Column 'file' cannot be null"
I have checked my codes, nothing wrong.. Please help me.
here is my code


Model


 public function savevideo(){
$post = $this->input->post();
$this->file = $this->UploadVideo();
return $this->db->insert($this->_tableigavideo, $this);
}
private function UploadVideo(){
$config['upload_path'] = './video';
$config['allowed_types'] = 'MP4';
$config['overwrite'] = true;
$config['max_size'] = 17500000;

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

if ($this->upload->do_upload('file')) {
return $this->upload->data("file_name");
}
}

Here is my Controller


public function addvideo(){
$indikator = $this->IndikatorModel;
$validation = $this->form_validation;
$validation->set_rules($indikator->rules());

if ($validation->run() == TRUE){
$indikator->savevideo();
$this->session->set_flashdata('success', 'Berhasil upload video');
redirect('indikator/index/'.$idiga);
}
}

Here is my View


      <label class="col-form-label col-sm-3" for="file"><b>Pilih File Mp4/Mov</b></label>
<div class="col-sm-9">
<input type="file" name="file" accept=".mp4">
</div>


My Answer:
you please provide more context or clarify your question?

Rate this post

4 of 5 based on 8484 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us