Welcome Guest, Not a member yet? Register   Sign In
Having problem uploading Photos and their thumbnails Concurrently
#1

[eluser]Unknown[/eluser]
Hey. I am uploading photos using 1 form, four of them, all at once. In the process, I am also generating their thumbs, however only the first photo's thumb gets created rest do not! Here is the code.

So I am using four of these, identical bits are the image thumbnail ones: So four of these are then called in the woman_form(). Okey so here is the file upload function which then generates thumbs on the go : followed by how I call those 4 functions while submitting the form.


Code:
function perform_file_upload_validation_1() {
        
        
        $config['upload_path'] = './uploads/';
  $config['allowed_types'] = '*';
  $config['max_size'] = '*';
  $config['max_width']  = '*';
  $config['max_height']  = '*';
  $config['encrypt_name'] = TRUE;
        
        $this->load->library('upload');
        $this->upload->initialize($config);
        $img_uploaded = $this->upload->do_upload("userfile");
            if ($img_uploaded){
            
            
            //$this->load->view('upload_view');
            $upload_data = $this->upload->data();
            $base =base_url();
   $add = "uploads/";
  
  
    //create thumbnails
    
            
               $tconfig['image_library'] = 'gd';
      $tconfig['source_image'] = './uploads/'.$upload_data['file_name'];
      $tconfig['new_image'] = './uploads/thumbs/'.$upload_data['file_name'];
      //$tconfig['create_thumb'] = TRUE;
      $tconfig['maintain_ratio'] = TRUE;
      $tconfig['width']  = 150;
      $tconfig['height'] = 150;
      $this->load->library('image_lib', $tconfig);
      //$this->image_lib->initialize($config);
      
      if ( ! $this->image_lib->resize())
      {
          echo $this->image_lib->display_errors();
      }
  
              
            
            //end of thumb-gen
  
  
  
   return $name1=  $base.$add.$upload_data['file_name'];
        }
        else{
            
  return $name1=  'No file selected';
            //$error = array('error' => $this->upload->display_errors());
            //$this->load->view('register_view' , $error);
        }
    }


------

This bit is from the form where I call them to upload/create thumbs if FORM has not failed:

Code:
$name1 = $this->perform_file_upload_validation_1();
  $name2 = $this->perform_file_upload_validation_2();
  $name3 = $this->perform_file_upload_validation_3();
  $name4 = $this->perform_file_upload_validation_4();
  
  
  
        if($query = $this->register_model->woman($name1,$name2,$name3,$name4))
        {






Theme © iAndrew 2016 - Forum software by © MyBB