Welcome Guest, Not a member yet? Register   Sign In
file upload fails but POST data looks fine (SOLVED - bug?)
#1

[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>
                    &lt;?php echo form_upload("upload_file"); ?&gt;
                </li>
                <li>
                    &lt;?php echo form_label('File Notes', 'file_notes');?&gt;
                    &lt;?php echo form_input($form_file_notes); ?&gt;
                </li>
            </ul>

            &lt;input type="submit" value="upload"/&gt;

        &lt;?php echo form_close(); ?&gt;                
    &lt;?php echo form_fieldset_close(); ?&gt;

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());
        }            
    }

}


Messages In This Thread
file upload fails but POST data looks fine (SOLVED - bug?) - by El Forum - 12-07-2010, 03:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB