Welcome Guest, Not a member yet? Register   Sign In
upload file problem
#1

[eluser]Krystian[/eluser]
Hi, I created upload folder in root. The file doesnt go. Why? This is almost pasted from documentation....
Code:
function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '500';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            $this->load->view('cms/worksError_view', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            // insert do bazy i gitara
            $this->load->view('cms/cms_view');
        }
    }
my form looks like this
Code:
<?php    
                    $data = array(
                       'name'        => 'fileUpload',
                    );
        
        
            echo form_open_multipart('main/do_upload');
            
                echo form_textarea('username');
                
                echo form_upload($data);
            
                echo form_submit('mysubmit', 'Add');
                
            echo form_close();
                
        ?>
when I printed the error array I got

You did not select a file to upload.

???

cheers
#2

[eluser]umefarooq[/eluser]
here is problem you have to pass your form file type name to do_upload function

Code:
$this->upload->do_upload('fileUpload')

try it, will work fine.
#3

[eluser]Boris Strahija[/eluser]
From the user guide:
By default the upload routine expects the file to come from a form field called userfile...

If you would like to set your own field name simply pass its value to the do_upload function:
Code:
$field_name = "some_field_name";
$this->upload->do_upload($field_name);




Theme © iAndrew 2016 - Forum software by © MyBB