• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to perform the upload with multiple files

#4
(08-21-2016, 11:08 AM)rikyperdana Wrote: Let me show you mine :

For the View :
Code:
<input type="file" multiple name="userfile[]" size="20"/>

For the controller :
Code:
$upload['upload_path'] = './uploads/';
$upload['allowed_types'] = 'gif|jpg|png';
$upload['max_size'] = 10000;
$upload['max_width'] = 4000;
$upload['max_height'] = 3000;

$files = $_FILES;
$count = count($_FILES['userfile']['name']);

for($i = 0; $i < $count; $i++) {
   $_FILES['userfile']['name']= $files['userfile']['name'][$i];
   $_FILES['userfile']['type']= $files['userfile']['type'][$i];
   $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
   $_FILES['userfile']['error']= $files['userfile']['error'][$i];
   $_FILES['userfile']['size']= $files['userfile']['size'][$i];    
   $this->upload->initialize($upload);
   $this->upload->do_upload();
}

Try upload some pics, if the pics you choose goes to 'uploads' folder, you did it
If it works for me, it should work for you too Smile

Hi, i have used your method and work very good but i don't know how to attach more files an e-mail. Can you help me please?

PHP Code:
$config['upload_path'         './media/images/uploads/';
 
               $config['allowed_types'       'gif|jpg|png|pdf';
 
               $config['max_size'            100;
 
               $config['max_width'           1024;
 
               $config['max_height'          768;

                
$files $_FILES;
                
$count count($_FILES['userfile']['name']);
                
                for(
$i 0$i $count$i++) {
                 
  $_FILES['userfile']['name'    $files['userfile']['name'][$i];
                 
  $_FILES['userfile']['type'    $files['userfile']['type'][$i];
                 
  $_FILES['userfile']['tmp_name'] = $files['userfile']['tmp_name'][$i];
                 
  $_FILES['userfile']['error'   $files['userfile']['error'][$i];
                 
  $_FILES['userfile']['size'    $files['userfile']['size'][$i]; 
 
  
                $this
->load->library('upload'$config);

 
               if ( ! $this->upload->do_upload('userfile'))
 
               {
 
                     $this->form_validation->set_error_delimiters('<p class="error">''</p>');
 
                     $error = array('error' => $this->upload->display_errors());
 
               }
 
               else
                
{
 
                    $upload_data $this->upload->data();
 
               }
 
               

$this->email->attach($upload_data['full_path']); 
Reply


Messages In This Thread
RE: How to perform the upload with multiple files - by eleumas - 09-13-2017, 07:16 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.