Commit e4afa009 by Phạm Văn Đoan

xử lý upload file

parent 6880f54a
......@@ -106,16 +106,29 @@ class CmsTrack extends CI_Controller
($singer || $id_user) ? $active_singer = 'update': $active_singer = 'insert';
($artist || $id_artist) ? $active_artist = 'update': $active_artist = 'insert';
// die($active_artist.$active_singer.'ca sĩ'.$id_singer.'/'.$singer.'nhạc sĩ'.$id_artists.'/'.$artist);
// Xử lý upload: avatar
$db_art_path = '';
$upload_path = 'uploads/tracks/arts';
$upload_full_path = '/home/aseanvn/public_html/vmusicchart.dcv.vn/' . $upload_path;
$config['upload_path'] = $upload_full_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 20480;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ($this->upload->do_upload('avatar')) {
$upload_data = $this->upload->data();
$db_art_path = $upload_path . '/' . $upload_data['file_name'];
}
$this->track_model->update_track_artists($contest_id, $id_artists, $id_artist, $active_artist);
$this->track_model->update_track_user($contest_id, $id_singer, $id_user, $active_singer);
$this->track_model->update($contest_id, $title);
// Ghi log
// $this->mactionlog->add('UPDATED', 'Cập nhật Cuộc đua thành công!', 'Mactionlog', 'action_log', $contest_id);
//
$this->session->set_flashdata('success', 'Cập nhật Cuộc đua thành công');
// }else{
// $this->session->set_flashdata('error', 'Cập nhật Cuộc đua không thành công');
// }
$this->track_model->update($contest_id, $title, $db_art_path);
$this->session->set_flashdata('success', 'Cập nhật bài hát thành công');
redirect(base_url().'backend/cmsTrack/listTrack');
}
}
......
......@@ -17,9 +17,10 @@ class Track_model extends CI_Model
return $insert_id;
}
public function update($id, $dataUpdate)
public function update($id, $dataUpdate, $art_path)
{
$this->db->set('title', $dataUpdate);
$this->db->set('art', $art_path);
$this->db->where('id', $id);
$this->db->update($this->_table);
}
......@@ -68,7 +69,7 @@ class Track_model extends CI_Model
$this->db->select($this->_table . '.*, track_user.name AS name_singer,
track_user.user_id AS id_singer,
track_artists.name AS artist,
track_artists.clear_name AS clear_artists, track_artists.id AS id_track_artist');
track_artists.id AS id_track_artist');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
......
......@@ -203,7 +203,7 @@ $action = $CI->router->fetch_method();
</li>
<!-- Quan ly tai nguyen -->
<li class="<?php if($controller && $controller == 'cmsResource') echo 'active open'?>">
<!--<li class="<?php /*if($controller && $controller == 'cmsResource') echo 'active open'*/?>">
<a href="#" class="dropdown-toggle">
<i class="menu-icon fa fa-camera"></i>
<span class="menu-text">QL Thư viện</span>
......@@ -211,14 +211,14 @@ $action = $CI->router->fetch_method();
</a>
<b class="arrow"></b>
<ul class="submenu">
<li class="<?php if($action && (in_array($action, array('listResource')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsResource/listResource'); ?>">
<li class="<?php /*if($action && (in_array($action, array('listResource')))) echo 'active'*/?>">
<a href="<?php /*echo base_url('backend/cmsResource/listResource'); */?>">
<i class="menu-icon fa fa-caret-right"></i>Danh sách tài nguyên
</a>
<b class="arrow"></b>
</li>
</ul>
</li>
</li>-->
<!-- Quan ly he thong -->
<?php if($CI->session->userdata('group_id') == 2 && $CI->session->userdata('is_super') == 1): ?>
......
......@@ -50,7 +50,7 @@ $input_artist = array(
} else {
$user_artist = $track_artists[0]['id'];
}
echo form_open(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id'].'/'.$user_singer.'/'.$user_artist), $attributes);
echo form_open_multipart(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id'].'/'.$user_singer.'/'.$user_artist), $attributes);
?>
<div class="form-group">
<label class="col-lg-3"></label>
......@@ -116,6 +116,13 @@ $input_artist = array(
</div>
<div class="form-group">
<label class="col-lg-3">Ảnh nhạc sĩ</label>
<div class="col-lg-3">
<input type="file" name="avatar" size="20" />
</div>
</div>
<div class="form-group">
<div class="col-lg-3">
<a href="<?php echo base_url().'backend/cmsTrack/listTrack'?>"
onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment