• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiupload not cycle

#1
I want to create a multi-upload function, but I can only upload one file.
The upload function does not cycle

View
PHP Code:
.....
.....
echo 
form_open_multipart('Upload');
echo 
'<br/>Upload file(s):<br />';
echo 
'<br />'.form_upload('files[]','','multiple');
echo 
'<br />'.form_upload('files[]','','multiple'); 
echo 
'<br />'.form_upload('files[]','','multiple');
echo 
'<br /><br />'.form_submit('submit','Upload');
echo 
form_close();
.....
..... 
Controller

PHP Code:
......
......
public function 
upload_do()
{
  $this->load->helper('form'); $data = array(); $messaggi='';
  $data['title'] = 'Multiple file upload';
  $number_of_files count($_FILES['files']['name']);
  $files $_FILES['files']; $errors = array();
  $this->load->library('upload');
  $config['upload_path'] = $this->session->userdata('upload');

  for ($i=0$i<$number_of_files$i++)
 
 {
   if($_FILES['files']['size'][$i]>0){
 
  $_FILES['files']['name'] = $files['name'][$i];
   $_FILES['files']['type'] = $files['type'][$i];
   $_FILES['files']['tmp_name'] = $files['tmp_name'][$i];
   $_FILES['files']['error'] = $files['error'][$i];
   $_FILES['files']['size'] = $files['size'][$i];
 
  $this->upload->initialize($this->set_upload_options());
 
  if ($this->upload->do_upload('files'))
 
  {
    data['uploads'][$i] = $this->upload->data();
    $nome_encrypt $data['uploads'][$i]['file_name'];
    foreach($this->upload->data() as $dati){echo 'filedata: '.$dati'<br/>'; }
 
  }
    else
    
{
     echo 'error: '.$this->upload->display_errors();
     $data['upload_errors'][$i] = $this->upload->display_errors();
    }
 
 }
}
 .......
 .......


Help me Confused

If I remove $ _FILES ['files'][ 'size'] the cycle works, but does not upload any file.
Reply


Messages In This Thread
Multiupload not cycle - by lucavalentino - 04-26-2016, 07:57 AM
RE: Multiupload not cycle - by InsiteFX - 04-26-2016, 01:13 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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