Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function do_upload()
- {
- $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
- $this->form_validation->set_rules('judul', 'judul', 'required');
- $this->form_validation->set_rules('ket', 'ket', 'required');
- $this->form_validation->set_rules('tgl', 'tgl', 'required');
- $this->form_validation->set_rules('berlaku', 'berlaku', 'required');
- if ($this->form_validation->run() == FALSE)
- {
- $header = array(
- 'title' =>'Welcome to my Website'
- );
- $content = array(
- 'article' =>'Lorem Ipsum Dolor Sit Amet'
- );
- $data['data_to_load'] = array($header,$content);
- $data['tmp_file']='promo/input';
- $this->load->view('index',$data);
- }
- else
- {
- $config['upload_path'] = "./gambar/"; //lokasi folder yang akan digunakan untuk menyimpan file
- $config['allowed_types'] = 'gif|jpg|png|JPEG'; //extension yang diperbolehkan untuk diupload
- $config['file_name'] = url_title($this->input->post('file_upload'));
- $this->upload->initialize($config); //meng set config yang sudah di atur
- if( !$this->upload->do_upload('file_upload'))
- {
- echo $this->upload->display_errors();
- }
- else{
- $data = array(
- 'gambar'=>$this->upload->file_name,
- 'judul' => $this->input->post('judul'),
- 'ket' => $this->input->post('ket'),
- 'tgl' => $this->input->post('tgl'),
- 'masa_berlaku' => $this->input->post('berlaku'),
- );
- //$this->crud->insert($data,'images');
- $this->promosi_model->addProduct($data);
- redirect('promosi');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement