avenirer / MY_Upload

An addition to the CI_Upload, that allows for multiple files upload.
38 stars 23 forks source link

get upload data when upload multiple inputs. #5

Open Noushid opened 7 years ago

Noushid commented 7 years ago

HTML

file1:<input type="file" name="userfiles1" multiple="">
file2:<input type="file" name="userfiles2" multiple="">

PHP

$this->upload->do_upload('userfiles1) ;
var_dump($this->upload->data());

$this->upload->do_upload('userfiles2');
var_dump($this->upload->data());

first var_dump output given below

array (size=2)
  0 => 
    array (size=14)
      'file_name' => string 'G_90935184.jpg' (length=14)
      'file_type' => string 'image/jpeg' (length=10)
      'file_path' => string '/home/project/public/uploads/' (length=55)
      'full_path' => string '/home/project/public/uploads/G_90935184.jpg' (length=69)
      'raw_name' => string 'G_90935184' (length=10)
      'orig_name' => string 'G_90935184.jpg' (length=14)
      'client_name' => string 'work-2.jpg' (length=10)
      'file_ext' => string '.jpg' (length=4)
      'file_size' => float 43.74
      'is_image' => boolean true
      'image_width' => int 425
      'image_height' => int 425
      'image_type' => string 'jpeg' (length=4)
      'image_size_str' => string 'width="425" height="425"' (length=24)
  1 => 
    array (size=14)
      'file_name' => string 'G_909351841.jpg' (length=15)
      'file_type' => string 'image/jpeg' (length=10)
      'file_path' => string '/home/project/public/uploads/' (length=55)
      'full_path' => string '/home/project/public/uploads/G_909351841.jpg' (length=70)
      'raw_name' => string 'G_909351841' (length=11)
      'orig_name' => string 'G_90935184.jpg' (length=14)
      'client_name' => string 'work-1.jpg' (length=10)
      'file_ext' => string '.jpg' (length=4)
      'file_size' => float 67.15
      'is_image' => boolean true
      'image_width' => int 425
      'image_height' => int 425
      'image_type' => string 'jpeg' (length=4)
      'image_size_str' => string 'width="425" height="425"' (length=24)

# second var_dump output is

array (size=4)
  0 => 
    array (size=14)
      'file_name' => string 'G_1096698198.jpg' (length=16)
      'file_type' => string 'image/jpeg' (length=10)
      'file_path' => string '/home/project/public/uploads/' (length=55)
      'full_path' => string '/home/project/public/uploads/G_1096698198.jpg' (length=71)
      'raw_name' => string 'G_1096698198' (length=12)
      'orig_name' => string 'G_1096698198.jpg' (length=16)
      'client_name' => string 'work-2.jpg' (length=10)
      'file_ext' => string '.jpg' (length=4)
      'file_size' => float 43.74
      'is_image' => boolean true
      'image_width' => int 425
      'image_height' => int 425
      'image_type' => string 'jpeg' (length=4)
      'image_size_str' => string 'width="425" height="425"' (length=24)
  1 => 
    array (size=14)
      'file_name' => string 'G_10966981981.jpg' (length=17)
      'file_type' => string 'image/jpeg' (length=10)
      'file_path' => string '/home/project/public/uploads/' (length=55)
      'full_path' => string '/home/project/public/uploads/G_10966981981.jpg' (length=72)
      'raw_name' => string 'G_10966981981' (length=13)
      'orig_name' => string 'G_1096698198.jpg' (length=16)
      'client_name' => string 'work-1.jpg' (length=10)
      'file_ext' => string '.jpg' (length=4)
      'file_size' => float 67.15
      'is_image' => boolean true
      'image_width' => int 425
      'image_height' => int 425
      'image_type' => string 'jpeg' (length=4)
      'image_size_str' => string 'width="425" height="425"' (length=24)
  2 => 
    array (size=2)
      0 => 
        array (size=14)
          'file_name' => string 'G_1096698198.jpg' (length=16)
          'file_type' => string 'image/jpeg' (length=10)
          'file_path' => string '/home/project/public/uploads/' (length=55)
          'full_path' => string '/home/project/public/uploads/G_1096698198.jpg' (length=71)
          'raw_name' => string 'G_1096698198' (length=12)
          'orig_name' => string 'G_1096698198.jpg' (length=16)
          'client_name' => string 'work-2.jpg' (length=10)
          'file_ext' => string '.jpg' (length=4)
          'file_size' => float 43.74
          'is_image' => boolean true
          'image_width' => int 425
          'image_height' => int 425
          'image_type' => string 'jpeg' (length=4)
          'image_size_str' => string 'width="425" height="425"' (length=24)
      1 => 
        array (size=14)
          'file_name' => string 'G_10966981981.jpg' (length=17)
          'file_type' => string 'image/jpeg' (length=10)
          'file_path' => string '/home/project/public/uploads/' (length=55)
          'full_path' => string '/home/project/public/uploads/G_10966981981.jpg' (length=72)
          'raw_name' => string 'G_10966981981' (length=13)
          'orig_name' => string 'G_1096698198.jpg' (length=16)
          'client_name' => string 'work-1.jpg' (length=10)
          'file_ext' => string '.jpg' (length=4)
          'file_size' => float 67.15
          'is_image' => boolean true
          'image_width' => int 425
          'image_height' => int 425
          'image_type' => string 'jpeg' (length=4)
          'image_size_str' => string 'width="425" height="425"' (length=24)
  3 => 
    array (size=3)
      0 => 
        array (size=14)
          'file_name' => string 'G_1096698198.jpg' (length=16)
          'file_type' => string 'image/jpeg' (length=10)
          'file_path' => string '/home/project/public/uploads/' (length=55)
          'full_path' => string '/home/project/public/uploads/G_1096698198.jpg' (length=71)
          'raw_name' => string 'G_1096698198' (length=12)
          'orig_name' => string 'G_1096698198.jpg' (length=16)
          'client_name' => string 'work-2.jpg' (length=10)
          'file_ext' => string '.jpg' (length=4)
          'file_size' => float 43.74
          'is_image' => boolean true
          'image_width' => int 425
          'image_height' => int 425
          'image_type' => string 'jpeg' (length=4)
          'image_size_str' => string 'width="425" height="425"' (length=24)
      1 => 
        array (size=14)
          'file_name' => string 'G_10966981981.jpg' (length=17)
          'file_type' => string 'image/jpeg' (length=10)
          'file_path' => string '/home/project/public/uploads/' (length=55)
          'full_path' => string '/home/project/public/uploads/G_10966981981.jpg' (length=72)
          'raw_name' => string 'G_10966981981' (length=13)
          'orig_name' => string 'G_1096698198.jpg' (length=16)
          'client_name' => string 'work-1.jpg' (length=10)
          'file_ext' => string '.jpg' (length=4)
          'file_size' => float 67.15
          'is_image' => boolean true
          'image_width' => int 425
          'image_height' => int 425
          'image_type' => string 'jpeg' (length=4)
          'image_size_str' => string 'width="425" height="425"' (length=24)
      2 => 
        array (size=2)
          0 => 
            array (size=14)
              'file_name' => string 'G_1096698198.jpg' (length=16)
              'file_type' => string 'image/jpeg' (length=10)
              'file_path' => string '/home/project/public/uploads/' (length=55)
              'full_path' => string '/home/project/public/uploads/G_1096698198.jpg' (length=71)
              'raw_name' => string 'G_1096698198' (length=12)
              'orig_name' => string 'G_1096698198.jpg' (length=16)
              'client_name' => string 'work-2.jpg' (length=10)
              'file_ext' => string '.jpg' (length=4)
              'file_size' => float 43.74
              'is_image' => boolean true
              'image_width' => int 425
              'image_height' => int 425
              'image_type' => string 'jpeg' (length=4)
              'image_size_str' => string 'width="425" height="425"' (length=24)
          1 => 
            array (size=14)
              'file_name' => string 'G_10966981981.jpg' (length=17)
              'file_type' => string 'image/jpeg' (length=10)
              'file_path' => string '/home/project/public/uploads/' (length=55)
              'full_path' => string '/home/project/public/uploads/G_10966981981.jpg' (length=72)
              'raw_name' => string 'G_10966981981' (length=13)
              'orig_name' => string 'G_1096698198.jpg' (length=16)
              'client_name' => string 'work-1.jpg' (length=10)
              'file_ext' => string '.jpg' (length=4)
              'file_size' => float 67.15
              'is_image' => boolean true
              'image_width' => int 425
              'image_height' => int 425
              'image_type' => string 'jpeg' (length=4)
              'image_size_str' => string 'width="425" height="425"' (length=24)

How can Fix this?