Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Upload extends CI_Controller {
- public function index()
- {
- $data['title'] = "Quality Health Safety Environment";
- $this->load->database();
- $data['data'] = $this->db->get('upload')->result();
- $this->load->view('create', $data, FALSE);
- }
- public function create()
- {
- if (isset($_POST['submit'])){
- $this->form_validation->set_rules('name', 'Name', 'required');
- $config['upload_path'] = './uploads/file';
- $config['allowed_types'] = 'pdf';
- $config['max_size'] = 2048;
- $config['encrypt_name'] = FALSE;
- // $config['max_height'] = 768;
- $this->load->library('upload', $config);
- // //file 1
- // if(!empty($_FILES['file1']))
- // {
- // $this->upload->do_upload('file1');
- // $data1= $this->upload->data();
- // $file1 = $data1['file_name'];
- // }
- //file2
- if(!empty($_FILES['file2']))
- {
- $this->upload->do_upload('file2');
- $data2= $this->upload->data();
- $file2 = $data2['file_name'];
- }
- if ($this->form_validation->run())
- {
- $name = $this->input->post('name', TRUE);
- $data = ['name'=>$name, 'file1'=>$file1, 'file2'=>$file2];
- $insert = $this->db->insert('upload', $data);
- if ($insert){
- $this->session->set_flashdata('pesan', '<div class="alert alert-succes"> Data Berhasil Disimpan </div>');
- redirect('upload');
- }
- }
- else
- {
- $this->index();
- }
- }
- else
- {
- $this->index();
- }
- function hapus($id)
- {
- $where = array('id' => $id);
- $this->MDL_upload->hapus_data($where,'upload');
- redirect('Upload');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement