Welcome Guest, Not a member yet? Register   Sign In
file upload in multiple paths
#2

[eluser]xwero[/eluser]
You can only load a library once and adding two initialize methods you just overwrite one setting array with the other. You have to use a loop to make this happen. The file fields can't be named userfile so you have to use separate names.
Code:
// view
<input type="file" name="image">
<input type="file" name="resume">
// controller
$files = array('image'=>array(’upload_path’=>‘./uploads/file1/’,’allowed_types’=>‘gif|jpg|png’,’max_size’=>100),
               'resume'=>array(’upload_path’=>‘./uploads/file2/’,’allowed_types’=>‘doc|rtf’,’max_size’=>100)
              );

$this->load->library(’upload’);

foreach($files as $field=>$settings)
{
   $this->upload->initialize($settings);
   if ( ! $this->upload->do_upload($field))
   {
     //error
   }
   else
   {
     // success
   }  
}


Messages In This Thread
file upload in multiple paths - by El Forum - 09-19-2008, 01:14 AM
file upload in multiple paths - by El Forum - 09-19-2008, 01:42 AM
file upload in multiple paths - by El Forum - 09-19-2008, 02:11 AM
file upload in multiple paths - by El Forum - 09-19-2008, 02:16 AM
file upload in multiple paths - by El Forum - 09-19-2008, 02:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB