Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function post_edit()
- {
- $data['title'] = 'My Post';
- $id = $this->input->post('id_post');
- $nmfes = $this->input->post('namaFes');
- $tempat = $this->input->post('tempat');
- $tanggal = $this->input->post('tanggal');
- $tanggal2 = $this->input->post('tanggal2');
- $uploadImg = $_FILES['image']['name'];
- if ($uploadImg) {
- $config['allowed_types'] = 'jpg|gif|png';
- $config['image_library'] = 'gd2';
- $config['create_thumb'] = FALSE;
- $config['maintain_ratio'] = FALSE;
- $config['quality'] = '50%';
- $config['overwrite'] = TRUE;
- $config['width'] = 600;
- $config['height'] = 400;
- $config['max_size'] = 2048;
- $config['encrypt_name'] = FALSE;
- $this->load->library('image_lib', $config);
- $this->image_lib->resize();
- $config['upload_path'] = './assets/img/posting/';
- $this->load->library('upload', $config);
- if ($this->upload->do_upload('image')) {
- $oldImg = $data['postfes']['image'];
- if ($oldImg != 'default.jpeg') {
- unlink(FCPATH . 'assets/img/posting/' . $oldImg);
- }
- $newImg = $this->upload->data('file_name');
- $this->db->set('image', $newImg);
- } else {
- $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert">' . $this->upload->display_errors() . '</div>');
- redirect('user/myPost');
- }
- }
- $data = array(
- 'id_post' => $id,
- 'namaFes' => $nmfes,
- 'tempat' => $tempat,
- 'tanggal' => $tanggal,
- 'tanggal2' => $tanggal2
- );
- $where = array(
- 'id_post' => $id
- );
- $this->PostModel->update_data($where, $data, 'postfes');
- $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Berhasil di terbitkan</div>');
- redirect('user/myPost');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement