<?php echo form_open_multipart("/upload"); ?>
  <input type="file" name="file1" /><br />
  <input type="file" name="file2" /><br />
  <input type="file" name="file3" /><br />
  <input type="file" name="file4" /><br />
<?php echo form_close(); ?>

<?php

$config = array();
$config['upload_path'] = 'media';
$config['allowed_types'] = 'jpg|jpeg|gif|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['max_filename'] = '1000';

for ($i = 1; $i <= 4; $i++)
{
  $file = $_FILES['file' . $i]['name'];

  $config['file_name'] = md5(time() . uniqid(true) . $file) . substr($file, strrpos($file, '.'));

  $this->load->library('upload', $config);

  if ($this->upload->do_upload('file' . $i))
  {
    $image = $this->upload->data();
  }
}
Published in: PHP
Download

Related snippets