Welcome Guest, Not a member yet? Register   Sign In
How uploading many files?
#1

[eluser]iniweb[/eluser]
Example i'am using File Class:

Code:
$this->load->library('upload', $this->config->config);
$this->upload->initialize($this->config->config);
$this->upload->do_upload('userfile', 'videofile');

Userfile - Image
Videofile - Media

But return only userfile:

Quote:Array ( [file_name] => drupal_ru.png [file_type] => image/png [file_path] => /home/yaba/html/uploads/images/ [full_path] => /home/yaba/html/uploads/images/drupal_ru.png [raw_name] => drupal_ru [orig_name] => [file_ext] => .png [file_size] => 130.66 [is_image] => 1 [image_width] => [image_height] => [image_type] => [image_size_str] => )
#2

[eluser]xwero[/eluser]
You can only validate/upload one file at the time using the upload class so you would have to do something like this
Code:
$fields = array('userfile','videofile');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_width']  = '1024';
$config['max_height']  = '768';
$config2['upload_path'] = './uploads/';
$config2['allowed_types'] = 'avi|wmv|mov';
foreach($fields as $field)
{
   if(isset($_FILES[$field]))
   {
      switch($field)
      {
         case 'userfile':
           $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            // error
        }    
        else
        {
            // success
        }
           break;
         case 'videofile':
           $this->load->library('upload', $config2);
    
        if ( ! $this->upload->do_upload())
        {
            // error
        }    
        else
        {
            // success
        }
           break;
      }
   }
}

It's a bit messy but i think you get the picture.




Theme © iAndrew 2016 - Forum software by © MyBB