Welcome Guest, Not a member yet? Register   Sign In
Multiple file upload problem
#6

[eluser]zsela[/eluser]
Thanks for the tip again, it worked fine.
Here is the solution, it might be handy for others in the future:

Code:
$config['upload_path'] = './images/uploads/realestates/';
$config['overwrite'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1024';
$config['max_width']  = '4000';
$config['max_height']  = '3000';
      
$this->load->library('upload');
      
$count = count(array_filter($_FILES['pic']['name']));
      
$this->Realestate_model->del_realestate_pictures($realestate_ID);
      
// upload files one-by-one
for ($i = 1; $i <= $count; $i++) {

  $_FILES['singlefile']['name'] = $_FILES['pic']['name'][$i];
  $_FILES['singlefile']['type'] = $_FILES['pic']['type'][$i];
  $_FILES['singlefile']['tmp_name'] = $_FILES['pic']['tmp_name'][$i];
  $_FILES['singlefile']['error'] = $_FILES['pic']['error'][$i];
  $_FILES['singlefile']['size'] = $_FILES['pic']['size'][$i];
        
  $index = ($i < 10)?'0'.$i:$i;
  $config['file_name'] = 'realestate_' . $realestate_ID . '_' . $index;
  $this->upload->initialize($config);
            
  if ($this->upload->do_upload('singlefile')) {
          
    $pr = ($primary == $i)?1:0;
        
    $pic_data = array('upload_data' => $this->upload->data());
    $this->Realestate_model->upload_realestate_pictures($realestate_ID, $pic_data['upload_data']['file_name'], $type[$i], $description[$i], $pr);
          
  } else {
        
    $page_data['pic' . $i . '_error'] = array('upload_error' => $this->upload->display_errors('<p class="error">', '</p>'));
      
    $page_data['realestate_ID'] = $realestate_ID;
    $page_data['pic_limit'] = $data['user_limit_pic'];      
    $this->load->view('realestate/upload_picture', array('page_data' => $page_data));
        
    return 0;
        
  }
        
)

Issue is closed!


Messages In This Thread
Multiple file upload problem - by El Forum - 11-15-2012, 03:34 PM
Multiple file upload problem - by El Forum - 11-15-2012, 03:56 PM
Multiple file upload problem - by El Forum - 11-15-2012, 04:04 PM
Multiple file upload problem - by El Forum - 11-15-2012, 04:17 PM
Multiple file upload problem - by El Forum - 11-15-2012, 04:20 PM
Multiple file upload problem - by El Forum - 11-19-2012, 03:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB