Welcome Guest, Not a member yet? Register   Sign In
Multiple image uploading
#1

[eluser]Unknown[/eluser]
I want to upload 2 images like My photo & family photo.

How to upload this 2 image in one form?

I have used folloeinf code in my form but it is not work:

<tr>
<td> My Photo : </td>
<td>&lt;input type="file" name="userfile" size="35" /&gt;</td>
</tr>
<tr>
<td> Family Photo : </td>
<td>&lt;input type="file" name="userfile" size="35" /&gt;</td>
</tr>


Need Help
#2

[eluser]xwero[/eluser]
it's best to use custom names
Code:
<tr>
<td> My Photo : </td>
<td>&lt;input type="file" name="myphoto" size="35" /&gt;</td>
</tr>
<tr>
<td> Family Photo : </td>
<td>&lt;input type="file" name="familyphoto" size="35" /&gt;</td>
</tr>
In the controller you have to loop through the files
Code:
$files = array('myphoto','familyphoto');
// config values
$this->library->load('upload',$config);
$i = 0;
foreach($_FILES as $file)
{
   if(!$this->upload->do($files[$i]))
   {
      // collect errors
   }
   else
   {
     // collect upload array
   }
   $i++;
}




Theme © iAndrew 2016 - Forum software by © MyBB