[eluser]Kemik[/eluser]
Hello,
Quote:Unable to find a post variable called userfile.
I get this error and I'm not sure why. The field is named userfile as requested in the user guide and the file uploads fine.
Controller
Code:
// Set avater config
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '50';
$config['max_width'] = '100';
$config['max_height'] = '100';
// Prepare form (already loaded url helper)
$this->load->helper('form');
$this->load->library('upload', $config);
$field_name = "userfile";
if ( ! $this->upload->do_upload($field_name)) {
$data['error'] = $this->upload->display_errors();
} else {
$upload = $this->upload->data();
// Update user
$this->user_model->update_avater($upload, $this->session->userdata('user_id'));
$data['uploaded'] = TRUE;
}
View
Code:
<?=form_open_multipart('user/edit_avater'); ?>
<table border="0" cellpadding="3" cellspacing="1">
<tr>
<td>Upload</td>
<td><?= form_upload('userfile'); ?></td>
</tr>
</table>
<input type="submit" class="submit" value="Upload" />
<?=form_close();?>
Thanks.