save image in database using codeigniter -


i want combine image along other data idnumber, name, , etc. i'm still confuse how can save folder , database cant show it

class addstudent extends ci_controller {       function indexes(){            if($this->session->userdata('logged_in'))         {             $session_data = $this->session->userdata('logged_in');              $data['username'] = $session_data['username'];             $this->load->view('addstudentinformation',$data);         } else{             redirect('welcome', 'refresh');         }            if((!isset($session_data) || $session_data !=true)) {              redirect('welcome', 'refresh');         }     }      function do_upload(){     $config['upload_path'] = './uploads/';     $config['allowed_types'] = 'gif|jpg|png|jpeg';     $config['overwrite'] = true;     $config['remove_spaces'] = true;     $config['max_size'] = '100';     $config['max_width'] = '1024';     $config['max_height'] = '768';     $this->upload->initialize($config);          $this->form_validation->set_rules('firstname', 'first name', 'trim|required');         $this->form_validation->set_rules('middlename', 'middle name', 'trim|required');         $this->form_validation->set_rules('lastname', 'last name', 'trim|required');         $this->form_validation->set_rules('idnumber', 'id number', 'trim|required');         $this->form_validation->set_rules('religion', 'religion', 'trim|required');         $this->form_validation->set_rules('mothertongue', 'mother tongue', 'trim|required');         $this->form_validation->set_rules('cellnumber', 'cell number', 'trim|required');         $this->form_validation->set_rules('age', 'age', 'trim|required');         $this->form_validation->set_rules('birthday', 'birthday', 'trim|required');         $this->form_validation->set_rules('sex', 'sex', 'trim|required');         $this->form_validation->set_rules('password', 'password', 'trim|required');         $this->form_validation->set_rules('fillform', 'fill form', 'trim|required');         $this->form_validation->set_rules('yearlevel', 'year level', 'trim|required');            $this->form_validation->set_rules('province', 'province', 'trim|required');         $this->form_validation->set_rules('town', 'town', 'trim|required');         $this->form_validation->set_rules('barrio', 'barrio', 'trim|required');         $this->form_validation->set_rules('permanentaddress', 'permanent address', 'trim|required');         $this->form_validation->set_rules('contactemergency', 'middlename', 'trim|required');         $this->form_validation->set_rules('contactnumber', 'contact number', 'trim|required');           if ($this->form_validation->run() == false){                $this->indexes();         }         else{        $images =   file_get_contents($_files['filetoupload']['tmp_name']);               $images = "filetoupload";            $this->upload->do_upload($images);          array('upload_data' =>  $this->upload->data());              $data= array(                         'firstname' => $this->input->post('firstname'),                         'middlename' => $this->input->post('middlename'),                         'lastname' => $this->input->post('lastname'),                                                 'idnumber' => $this->input->post('idnumber'),                         'religion' => $this->input->post('religion'),                         'mothertongue' => $this->input->post('mothertongue'),                                                 'cellphonenumber' => $this->input->post('cellnumber'),                         'age' => $this->input->post('age'),                         'dateofbirth' => $this->input->post('birthday'),                                                 'sex' => $this->input->post('sex'),                         'password' => $this->input->post('password'),                         'datefilled' => $this->input->post('fillform'),                                                 'yearlevel' => $this->input->post('yearlevel'),                                          'imageupload'=> $images,                          'province' => $this->input->post('province'),                                                 'town' => $this->input->post('town'),                         'barrio' => $this->input->post('barrio'),                         'permanentaddress' => $this->input->post('permanentaddress'),                                                 'contactperson' => $this->input->post('contactemergency'),                         'contactpersonnumber' => $this->input->post('contactnumber'),                       );              $this->db->insert('studentinformation',$data);            redirect('educationalbackground/index', refesh);           }       } 

and how view database

  <img alt="uploaded image" src="<?php echo base_url( 'uploads/'. $r-> imageupload)  ?>"> 


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -