Welcome Guest, Not a member yet? Register   Sign In
Avoid re-upload on multiple uploads. (If error appear)
#1

[eluser]Ignacio[/eluser]
Hello everybody, I'm using this code from xwero to do the multiple uploads, multiple folders and multiple configs, works great!:
Code:
// MY_Upload.php
class MY_Upload extends CI_Upload
{
   function multi_upload($configs,$files)
   {
    
    if(count($configs) != count($files))
    {
       return 'array_count_wrong';
    }
    
    $errors = $successes = array();

    for($i=0, $j = count($files);$i<$j;$i++)
    {
       $this->initialize($configs[$i]);

       if( ! $this->do_upload($files[$i]))
       {
           $errors[$files[$i]] = $this->display_errors();
       }
       else
       {
           $successes[$files[$i]] = $this->data();
       }
    }

    return array($errors, $successes);
  }
}
// controller
$this->load->library('upload');

$config[0]['upload_path'] = './_uploads/images/';
            $config[0]['allowed_types'] = 'gif|jpg|png';
            $config[0]['max_size']    = '1000';
            $config[0]['max_width']  = '50';
            $config[0]['max_height']  = '50';
            $config[1]['upload_path'] = './_uploads/flv/';
            $config[1]['allowed_types'] = 'flv';
            $config[1]['max_size']    = '30000';

            // files
            $files[0] = 'userfile_0';
            $files[1] = 'userfile_1';

            // upload
            $messages = $this->upload->multi_upload($config,$files);

Now, the problem (nobody ask this before). Check the controller on the example, I'm using two fields, so, two files to upload, lets say file1 and file2.

If file1 do the upload fine and file2 not, what happen? Retrieve an error for file2, that's excellent, but what happen with file1? you need to re-upload again! I don't want that! Any idea of how can I improve a solution for this?

Thanks!


Messages In This Thread
Avoid re-upload on multiple uploads. (If error appear) - by El Forum - 11-07-2008, 02:24 AM
Avoid re-upload on multiple uploads. (If error appear) - by El Forum - 11-07-2008, 04:21 AM
Avoid re-upload on multiple uploads. (If error appear) - by El Forum - 11-07-2008, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB