CodeIgniter Forums
[SOLVED] Upload 2 files with diferent configuration - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: [SOLVED] Upload 2 files with diferent configuration (/thread-7495.html)



[SOLVED] Upload 2 files with diferent configuration - El Forum - 04-11-2008

[eluser]Lagarto[/eluser]
I'm trying to upload (using file upload library) 2 files from the same form, but each of this files have a diferent "config", i've tested this code and it seems that only take the first config/library loading.

Code:
$config['upload_path'] = 'public/uploaded';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '10000';
$config['max_width']  = '190';
$config['max_height']  = '125';
//$config['max_width']  = '600';
//$config['max_height']  = '395';                

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

if($this->upload->do_upload("img_thumb"))
{
    //agafo nom d'abans
    $data = $this->upload->data();
    $nom_thumb = $data['file_name'];

    $config['upload_path'] = 'public/uploaded';
    $config['allowed_types'] = 'gif|jpg|png|swf';
    $config['max_size']    = '10000';
    $config['max_width']  = '600';
    $config['max_height']  = '395';
    
    $this->load->library('upload', $config);

    if($this->upload->do_upload("img_gran"))
    {
        //agafo nom d'abans
        $data = $this->upload->data();
        $nom_gran = $data['file_name'];
        //insert
        $nombre = $_POST['nombre'];
        $fecha = time();
        $idioma=1;
        $texto = $_POST['texto'];
        $insert = array($nombre, $fecha, $idioma, $texto, $nom_thumb, $nom_gran);
        $this->db->query("INSERT INTO `realisations` (`nombre`, `fecha`, `idioma`, `texto`, `img_thumb`, `img_gran`) VALUES (?, ?, ?, ?, ?, ?)", $insert);
        redirect('realisations/index/created_ok');
    }    
    else
    {
        redirect('realisations/add/error_ok/2');
        //echo $this->upload->display_errors();
    }
}    
else
{
    redirect('realisations/add/error_ok/1');
    //echo "error 1";
    //echo $this->upload->display_errors();
}

Am I doing something wrong? Bug spotted?

Thanks! Big Grin


[SOLVED] Upload 2 files with diferent configuration - El Forum - 04-11-2008

[eluser]PauloBr[/eluser]
Hello!

I'm not sure about this, but try initialize by this way:

Code:
$this->upload->initialize($config);

[]'s


[SOLVED] Upload 2 files with diferent configuration - El Forum - 04-11-2008

[eluser]Lagarto[/eluser]
That's it! Thanks Wink