CodeIgniter Forums
Image upload to mysql database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Image upload to mysql database (/showthread.php?tid=1205)



Image upload to mysql database - vidhyaprakash85 - 02-18-2015

I want to upload the image to the mysql database for storing many information. I have attached the 3 (MVC) code for your reference and please help me.

View
PHP Code:
<form class="form-horizontal" action="edit_profile/update_profile" id="edit_profile_form_validation" method="post" enctype="multipart/form-data">
 <
div class="form-group"><label class="col-sm-2 control-label">Photo</label>
 
                               <div class="col-sm-10"><input type="file" name="photo" class="form-control">
 
                               </div>
 
                           </div>
 
                           <div class="form-group">
 
                               <div class="col-sm-4 col-sm-offset-2">
 
                                   <button class="btn btn-white" type="submit">Cancel</button>
 
                                   <button class="btn btn-primary" type="submit">Save changes</button>
 
                               </div>
 
                           </div>
 
                       </form
Controller
PHP Code:
 public function update_profile() {
       $id $this->session->userdata('id');
       $this->load->model('edit_profile_model');
       $this->edit_profile_model->update_db_user_info($id);
   
Model
PHP Code:
public function update_db_user_info($id) {
       $data = array(
           'fullname' => $this->input->post('fullname'),
           'address' => $this->input->post('address'),
          'state' => $this->input->post('state'),
           'city' => $this->input->post('city'),
           'pincode' => $this->input->post('pincode'),
           'image' => $this->input->post('photo'),
       );
       $this->db->where('id'$id);
       $this->db->update('userdetails'$data);
   

in view i have shown only image upload code it has many code. Please help me how to complete the work.


RE: Image upload to mysql database - vidhyaprakash85 - 02-19-2015

Please help me guys


RE: Image upload to mysql database - Rufnex - 02-20-2015

I think you will upload the selected file to your webservers upload directory and not store the data as blob into your database.
To handle the upload you have to follow the steps described here:

http://www.codeigniter.com/userguide3/libraries/file_uploading.html


RE: Image upload to mysql database - vidhyaprakash85 - 02-20-2015

Thanx sir