Welcome Guest, Not a member yet? Register   Sign In
Multi upload
#1

I'm trying to create a control for upload multiple files

My controll:

PHP Code:
public function do_upload($path$subpath) {
 
   $files $_FILES['file']; $file ['file']=array();
 
   $num_file count($_FILES['file']['name']);
 
   echo $path;
 
   for ($i 1$i <= $num_file$i++) {
 
     if (isset($files[$i])) {
 
      $this->_CI->session->set_userdata(array('filename' => $files['name'][$i]));
 
      $this->load->library('upload'$this->set_upload_options());
 
      $this->upload->initialize($this->set_upload_options());
 
      chmod($path0777); chmod($subpath0777);
 
      $this->upload->do_upload($files[$i]);
 
      $error = array('error' => $this->upload->display_errors());
 
      foreach ($error as $errore)
 
       echo 'Errore: '.$errore;
 
      }
 
   }
}
 public function 
set_upload_options(){
 
// upload an image options
 
 $image ='gif|jpg|png|GIF|JPG|PNG';
 
 $config['upload_path'] = $this->session->userdata('subdir');
 
 $config['allowed_types'] = $image;
 
  $config['overwrite'] = TRUE;
 
  if (!empty($this->session->userdata('filename'))) {
 
     $config['file_name'] = $this->session->userdata('filename');
 
   }
 
   $config['max_size'] = 100;
 
   $config['max_width'] = 1024;
 
   $config['max_height'] = 768;
 
   $config ['encrypt_name'] = TRUE;

 
   return $config;
    } 

View
PHP Code:
....
....
.....
<?
php echo form_open_multipart('upload');?>
<?php 
echo form_upload('file[]','','multiple'); ?>
<input type="submit" value="upload" />

</form> 


I do not receive any error, but the file does not load

I do not know what to think.

Help me.

Thank you
Reply
#2

(This post was last modified: 12-09-2015, 04:58 PM by solidcodes.)

Try comparing your codes with this tutorial or just follow this tutorial below,
http://avenir.ro/codeigniter-tutorials/u...deigniter/
No SEO spam
Reply
#3

Tank you for help me Smile
Reply
#4

(This post was last modified: 12-14-2015, 03:51 PM by meow.)

(12-09-2015, 04:08 PM)solidcodes Wrote: Try comparing your codes with this tutorial or just follow this tutorial below,
http://avenir.ro/codeigniter-tutorials/u...deigniter/

As of 2015 Winter, found the updated version here:
https://github.com/avenirer/MY_Upload
Reply




Theme © iAndrew 2016 - Forum software by © MyBB