Welcome Guest, Not a member yet? Register   Sign In
Image upload to mysql database
#1

(This post was last modified: 02-19-2015, 11:43 AM by vidhyaprakash85.)

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.
Reply
#2

Please help me guys
Reply
#3

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/li...ading.html

Reply
#4

Thanx sir
Reply




Theme © iAndrew 2016 - Forum software by © MyBB