CodeIgniter Forums
Unable to find a post variable called userfile - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Unable to find a post variable called userfile (/showthread.php?tid=11684)



Unable to find a post variable called userfile - El Forum - 09-19-2008

[eluser]PHP Programmer[/eluser]
I am getting the following error on uploading the files:
"Unable to find a post variable called userfile"

Although, I have assigned the following:

<input type="file" name="userfile1" id="userfile1" />
<td>&lt;input type="file" name="userfile2" id="userfile2" /&gt;&lt;/td>
<td>&lt;input type="file" name="userfile3" id="userfile3" /&gt;&lt;/td>
<td>&lt;input type="file" name="userfile4" id="userfile4" /&gt;&lt;/td>
<td>&lt;input type="file" name="userfile5" id="userfile5" /&gt;
&lt;input type="file" name="userfile6" id="userfile6" /&gt;
&lt;input type="file" name="userfile7" id="userfile7" /&gt;

How can I remove that error??


Unable to find a post variable called userfile - El Forum - 09-19-2008

[eluser]xwero[/eluser]
file inputs are stored in the $_FILES global.


Unable to find a post variable called userfile - El Forum - 09-19-2008

[eluser]PHP Programmer[/eluser]
After that, I did the following in controller:

$config['upload_path'] = './uploads/Employer/Photo/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2048'; //2 meg
$this->load->library('upload', $config);
foreach($_FILES as $key => $value)
{
//print_r($value);
if( ! empty($key))
{
$this->upload->initialize($config);
if ( ! $this->upload->do_upload($key))
{
echo "here";
print_r($errors[] = $this->upload->display_errors());
}
else
{
echo "this";
$data = array('upload_data' => $this->upload->data());
//$this->Process_image->process_pic();
}
}
}

And, it always goes in error message. How to resolve this??


Unable to find a post variable called userfile - El Forum - 09-21-2008

[eluser]llbbl[/eluser]
the userguide helps alot . did you try rereading it?

if your still stuck i'll try to debug your code. you should get in habit of trying to problem solve and figure it out for yourself. you can't always rely on the forums. they become a bad crutch. Smile