Welcome Guest, Not a member yet? Register   Sign In
Battling to upload multiple files
#1

[eluser]giovannidc[/eluser]
Hi,

I'm trying to upload multiple images but my code only seems to work on my localhost. When I try upload on a live server, only one file is uploaded.

I googled and alot of the responses said I need to use
Code:
$this->upload->initialize($config);
before using the
Code:
$this->upload->do_upload('image'.$i)
but my results remain the same with only one file being uploaded.

Here is an extract of my code, please let me know what I am missing:

Code:
$upload_errors = array();
$this->load->library('upload');
$this->load->library('image_lib');
  
        
for ($i = 15; $i <= 15; $i++)
{

$config['upload_path'] = '././filestore/listings/images';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1240';
$config['encrypt_name']  = 'TRUE';
$this->upload->initialize($config);
if ($this->upload->do_upload('listing_image'.$i))
{
  $upload_data = $this->upload->data();
  
  //resize image
  $edit_config['image_library']  = 'gd2';
  $edit_config['source_image']  = $upload_data['full_path'];
  $edit_config['create_thumb']  = FALSE;
  $edit_config['maintain_ratio']  = FALSE;
  $edit_config['width']    = 770;
  $edit_config['height']   = 386;
  
  $this->image_lib->initialize($edit_config);
  $this->image_lib->resize();
  $this->image_lib->clear();
  
  
  $this->db->insert('images', $upload_data);
  $this->db->trans_complete();
  
}
else
{
  $upload_error = array();
  $upload_error['error_details']  = $this->upload->display_errors('','');
  $upload_error['image_ref']  ='Gallery Image '.$i;
  
  if ($upload_error['error_details']!="You did not select a file to upload.")
  {
   $upload_errors[] = $upload_error;
  }
}
}
#2

[eluser]giovannidc[/eluser]
Problem solved. I accidentally had a redirect in my loop that redirected to to the success page.




Theme © iAndrew 2016 - Forum software by © MyBB