- Beranda
- Website, Webmaster, Webdeveloper
Tanya - Upload Video di codeigniter
...
TS
clonningdash
Tanya - Upload Video di codeigniter
Gan saya mau tanya video berhasil keupload ke path folder yang diarahkan ,sedangkan data nya tidak masuk kedalam database .
Mohon petunjuknya
Makasih gan
Mohon petunjuknya
Quote:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends CI_Controller {
public function __construct() {
parent::__construct();
date_default_timezone_set('Asia/Jakarta');
$this->load->model('m_login');
if($this->session->userdata('status')!="telah_login"){
redirect(base_url().'login?alert=not logged in');
}
}
public function upload_video()
{
if (isset($_FILES['video']['name']) && $_FILES['video']['name'] != '') {
unset($config);
$video_created = date("ymd");
$configVideo['upload_path'] = './video';
$configVideo['max_size'] = '0';
$configVideo['allowed_types'] = 'avi|flv|wmv|mp3|mp4';
$configVideo['overwrite'] = FALSE;
$configVideo['remove_spaces'] = TRUE;
$video_name = $video_created.$_FILES['video']['name'];
$configVideo['file_name'] = $video_name;
$this->load->library('upload', $configVideo);
$this->upload->initialize($configVideo);
if(!$this->upload->do_upload('video')) {
$videoDetails = $this->upload->data();
$video_created = date('Y-m-d H:i:s');
$video_title = $this->input->post('video_title');
$video = $video_filename['file_name'];
$video_author = $this->session->userdata('id');
$video_status = $this->input->post('status');
$data ['video_name']= $configVideo['file_name'];
$data['video_detail'] = $videoDetails;
$data = array(
'video_created' => $video_created,
'video_title' => $video_title,
'video_filename' => $video_filename,
'video_author' => $video_author,
'video_status' => $video_status,
);
$this->m_login->insert_data($data,'video');
redirect (base_url().'dashboard/video');
}else{
$this->load->view('dashboard/header');
$this->load->view('dashboard/video');
$this->load->view('dashboard/footer');
}
}else{
echo "Please select a file";
}
}
}
defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends CI_Controller {
public function __construct() {
parent::__construct();
date_default_timezone_set('Asia/Jakarta');
$this->load->model('m_login');
if($this->session->userdata('status')!="telah_login"){
redirect(base_url().'login?alert=not logged in');
}
}
public function upload_video()
{
if (isset($_FILES['video']['name']) && $_FILES['video']['name'] != '') {
unset($config);
$video_created = date("ymd");
$configVideo['upload_path'] = './video';
$configVideo['max_size'] = '0';
$configVideo['allowed_types'] = 'avi|flv|wmv|mp3|mp4';
$configVideo['overwrite'] = FALSE;
$configVideo['remove_spaces'] = TRUE;
$video_name = $video_created.$_FILES['video']['name'];
$configVideo['file_name'] = $video_name;
$this->load->library('upload', $configVideo);
$this->upload->initialize($configVideo);
if(!$this->upload->do_upload('video')) {
$videoDetails = $this->upload->data();
$video_created = date('Y-m-d H:i:s');
$video_title = $this->input->post('video_title');
$video = $video_filename['file_name'];
$video_author = $this->session->userdata('id');
$video_status = $this->input->post('status');
$data ['video_name']= $configVideo['file_name'];
$data['video_detail'] = $videoDetails;
$data = array(
'video_created' => $video_created,
'video_title' => $video_title,
'video_filename' => $video_filename,
'video_author' => $video_author,
'video_status' => $video_status,
);
$this->m_login->insert_data($data,'video');
redirect (base_url().'dashboard/video');
}else{
$this->load->view('dashboard/header');
$this->load->view('dashboard/video');
$this->load->view('dashboard/footer');
}
}else{
echo "Please select a file";
}
}
}
Quote:
<?php
class M_login extends CI_Model{
function cek_login($table,$where)
{
return $this->db->get_where($table,$where);
}
function update_data($where,$data,$table)
{
$this->db->where($where);
$this->db->update($table,$data);
}
//mengambil data dari database
function get_data($table){
return $this->db->get($table);
}
//insert data category
function insert_data($data,$table)
{
$this->db->insert($table,$data);
}
//edit data
function edit_data($where,$table)
{
return $this->db->get_where($table,$where);
}
//delete data
function delete_data($where,$table)
{
$this->db->delete($table,$where);
}
function GetParentMenu($table){
$query = "SELECT * FROM menu WHERE parent_id = '0' AND status = '1' order by menu_id asc";
return $this->db->query($query);
}
}
?>
class M_login extends CI_Model{
function cek_login($table,$where)
{
return $this->db->get_where($table,$where);
}
function update_data($where,$data,$table)
{
$this->db->where($where);
$this->db->update($table,$data);
}
//mengambil data dari database
function get_data($table){
return $this->db->get($table);
}
//insert data category
function insert_data($data,$table)
{
$this->db->insert($table,$data);
}
//edit data
function edit_data($where,$table)
{
return $this->db->get_where($table,$where);
}
//delete data
function delete_data($where,$table)
{
$this->db->delete($table,$where);
}
function GetParentMenu($table){
$query = "SELECT * FROM menu WHERE parent_id = '0' AND status = '1' order by menu_id asc";
return $this->db->query($query);
}
}
?>
Quote:
<div class="content-wrapper">
<section class="content-header">
<h1>Video<small>Add New Video</small></h1>
</section>
<section class="content">
<a href="<?php echo base_url().'dashboard/video'; ?>" class="btn btn-sm btn-primary">Back</a>
<br/>
<br/>
<form method="post" action="<?php echo base_url('dashboard/upload_video') ?>" enctype="multipart/form-data">
<div class="row">
<div class="col-lg-9">
<div class="box box-primary">
<div class="box-body">
<div class="box-body">
<div class="form-group">
<label>Title</label>
<input type="text" name="title" class="form-control" placeholder="Enter Video Title" value="<?php echo set_value('video_title'); ?>" required>
<br/>
<?php echo form_error('video_title'); ?>
</div>
</div>
<div class="box-body">
<div class="form-group">
<label>Video</label>
<input class="btn btn-default form-control" type="file" name="video" id="video"required>
</div>
</div>
<br/>
<br/>
<input type="submit" name="status" value="Draft" class="btn btn-warning btn-block">
<input type="submit" name="status" value="Publish" class="btn btn-success btn-block">
</div>
</div>
</div>
</form>
</section>
</div>
<section class="content-header">
<h1>Video<small>Add New Video</small></h1>
</section>
<section class="content">
<a href="<?php echo base_url().'dashboard/video'; ?>" class="btn btn-sm btn-primary">Back</a>
<br/>
<br/>
<form method="post" action="<?php echo base_url('dashboard/upload_video') ?>" enctype="multipart/form-data">
<div class="row">
<div class="col-lg-9">
<div class="box box-primary">
<div class="box-body">
<div class="box-body">
<div class="form-group">
<label>Title</label>
<input type="text" name="title" class="form-control" placeholder="Enter Video Title" value="<?php echo set_value('video_title'); ?>" required>
<br/>
<?php echo form_error('video_title'); ?>
</div>
</div>
<div class="box-body">
<div class="form-group">
<label>Video</label>
<input class="btn btn-default form-control" type="file" name="video" id="video"required>
</div>
</div>
<br/>
<br/>
<input type="submit" name="status" value="Draft" class="btn btn-warning btn-block">
<input type="submit" name="status" value="Publish" class="btn btn-success btn-block">
</div>
</div>
</div>
</form>
</section>
</div>
Makasih gan
0
608
Kutip
1
Balasan
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Mari bergabung, dapatkan informasi dan teman baru!
Website, Webmaster, Webdeveloper
23.3KThread•4.3KAnggota
Terlama
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru