Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------Controller-------------------
- function administrasi_tambah() {
- if($this->session->userdata('sudah_login_pelamar')){
- if ( isset($file['upload_message'])){
- print_r($file);exit;
- $array = array( 'content' => $this->load->view('akun_pelamar/gagal','',true) );
- $this->load->view('akun_pelamar/menu', $array);
- }else{
- $reg['query'] = $this->pelamar_model->tambahkelengkapan();
- if($reg['query']) {
- $array = array( 'content' => $this->load->view('akun_pelamar/sukses','',true) );
- $this->load->view('akun_pelamar/menu', $array);
- }
- }
- }else {
- redirect('index/index');
- }
- }
- --------------------Model--------------------
- function tambahkelengkapan() {
- $no=$this->input->post('no_urut');
- $config['upload_path'] = './uploads/';
- $config['allowed_types'] = 'gif|jpg|jpeg|jpe|png|pdf';
- $this->load->library('upload');
- foreach ($_FILES as $key => $value)
- {
- if (!empty($key['name']))
- {
- // ini yang dibutuhkan
- $filename = 'GE'.$no.'name_'.mt_rand();
- // ini untuk nama file pada saat upload
- $config['file_name'] = $filename;
- $this->upload->initialize($config);
- if (!$this->upload->do_upload($key))
- {
- $errors = $this->upload->display_errors();
- return FALSE;
- }
- else
- {
- $query1 = $this->db->query("SELECT * FROM form WHERE type != '0'");
- $result = $query1->result();
- $i=0;
- $len=count($result);
- $emprit= "INSERT INTO penilaian (no_urut,";
- foreach($result as $row){
- if($i == $len - 1) {
- $emprit .= "".$row->nama."";
- }else{
- $emprit .= "".$row->nama.",";
- }
- $i++;
- }
- $emprit .= ") VALUES ('".$_POST['no_urut']."',";
- $a=0;
- foreach($result as $row){
- if($a == $len - 1) {
- if($row->type == 'file'){
- $emprit .= "'".$filename."'";
- }else{
- $emprit .= "'".$_POST[$row->nama]."'";
- }
- }else{
- if($row->type == 'file'){
- $emprit .= "'".$filename."',";
- }else{
- $emprit .= "'".$_POST[$row->nama]."',";
- }
- }
- $a++;
- }
- $emprit .= ");";
- $query = $this->db->query($emprit);
- return $query;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment