Welcome Guest, Not a member yet? Register   Sign In
Upload issue!
#1

[eluser]the_unforgiven[/eluser]
Here's my controller and model that uploads the image to both the uploads folder then resizes, but i need to change this to allow at least 4 uploads at once how can i do this based on my code?

Code:
[b]Controller:[/b]
function __construct()
{
      parent::__construct();
   session_start();
      $this->gallery_path = realpath(APPPATH . '/../uploads');
      $this->gallery_path_url = base_url().'uploads/';
    
  
}
function _do_upload_file()
{
  
    //upload config
  $config = array(
   'allowed_types' => 'jpg|jpeg|gif|png|pdf',
   'upload_path' => $this->gallery_path,
   'max_size' => 6000,
   'overwrite' => false,
      'remove_spaces' => true
  );
  
     $this->load->library('upload', $config);
  $this->upload->initialize($config);  
  
     if (!$this->upload->do_upload())
     {
         $this->form_validation->set_message('_do_upload_file', $this->upload->display_errors());
         return FALSE;
     }
     else
     {
  // Resize Config
   $config['image_library'] = 'gd2';
   $config['create_thumb'] = TRUE;
   $config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
   $config['new_image'] = $this->gallery_path . '/thumbs';
   $config['maintain_ratio'] = TRUE;
   $config['width'] = 150;
         //echo $this->upload->upload_path.$this->upload->file_name . "<BR>";  
   $config['height'] = 100;
  
   $this->load->library('image_lib', $config);
   $this->image_lib->initialize($config);
   $this->image_lib->resize();
    
   if (!$this->image_lib->resize()){
          $this->form_validation->set_message('_do_upload_file', $this->upload->display_errors());              
   }
  
  }

}

Code:
[b]Model[/b]
function addproduct(){
  
  $data = array(  
   'name' => $this->input->post('name'),
   'short_description' => $this->input->post('short_description'),
   'long_description' => $this->input->post('long_description'),
   'status' => $this->input->post('status'),
   'category' => $this->input->post('category'),
   'featured' => $this->input->post('featured'),
   'price' => $this->input->post('price'),
   'code' => $this->input->post('code'),
   'supplier' => $this->input->post('supplier'),
   'supplier_code' => $this->input->post('supplier_code'),
   'weight' => $this->input->post('weight'),
   'stock' => $this->input->post('stock'),
   'color' => $this->input->post('color'),
   'sizes' => $this->input->post('sizes')
  
  );
  $image_data = $this->upload->data();
  $data['image'] = $image_data['file_name'];
  
  $this->db->insert('products', $data);
  redirect('admin/products');
  
  }

So based on this can someone help show/explain how i can change this code to allow 4 uploads! in to 4 separate fields in the database, which is:
Code:
id  name  short_description  long_description  image  image2  image3  image4  status


Messages In This Thread
Upload issue! - by El Forum - 05-08-2012, 11:56 AM
Upload issue! - by El Forum - 05-08-2012, 12:03 PM
Upload issue! - by El Forum - 05-08-2012, 12:09 PM
Upload issue! - by El Forum - 05-08-2012, 12:15 PM
Upload issue! - by El Forum - 05-08-2012, 12:18 PM
Upload issue! - by El Forum - 05-08-2012, 12:33 PM
Upload issue! - by El Forum - 05-08-2012, 12:42 PM
Upload issue! - by El Forum - 05-09-2012, 05:23 AM
Upload issue! - by El Forum - 05-09-2012, 06:07 AM
Upload issue! - by El Forum - 05-09-2012, 06:08 AM
Upload issue! - by El Forum - 05-09-2012, 06:15 AM
Upload issue! - by El Forum - 05-09-2012, 06:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB