[eluser]munkeh[/eluser]
I'm trying to upload a file and while the form seems to be working the upload helper gives me an error: You did not select a file to upload.
The POST data is fine:
$_POST['upload_file'] test.jpg
$_POST['file_notes'] test
permissions on the /var/www/website/htdocs/system/uploads directory are fine. PHP config as follows:
file_uploads on
max_file_uploads 20
upload_max_filesize 2M
What am I doing wrong?
My view:
Code:
<?php echo form_fieldset('upload'); ?>
<?php echo form_open_multipart('add_claim/upload_file', 'name="upload_form"');?>
<ul>
<li>
<?php echo form_upload("upload_file"); ?>
</li>
<li>
<?php echo form_label('File Notes', 'file_notes');?>
<?php echo form_input($form_file_notes); ?>
</li>
</ul>
<input type="submit" value="upload"/>
<?php echo form_close(); ?>
<?php echo form_fieldset_close(); ?>
My Controller:
Code:
function upload_file() {
$this->form_validation->set_rules('file_notes','lang:file_notes','trim|max_length[256]');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
if ($this->form_validation->run() == FALSE)
{
$form_file_notes = array(
'name' => 'file_notes',
'id' => 'file_notes',
'value' => set_value('file_notes'),
'maxlength' => '256'
);
$data['form_file_notes'] = $form_file_notes;
$data['main_content'] = 'claim/upload_file';
$this->load->view('includes/template', $data);
}
else
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = 'true';
$config['remove_spaces'] = 'true';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('upload_file'))
{
print_r($this->upload->display_errors());
}
else
{
print_r($this->upload->data());
}
}
}