Welcome Guest, Not a member yet? Register   Sign In
Picture Upload Problem : "You did not select a file to upload."
#1

[eluser]vasily[/eluser]
I want to post news from admin panel and add a thumbnail image for this news. My controller function is this:
Code:
function add_thumb(){
    $config['upload_path'] = './pictures/';
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['max_size']    = '1000';


    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload()){
        $error = array('error' => $this->upload->display_errors());
                $this->load->view('admin_panel', $error);
    }
    else{
        $data = array('upload_data' => $this->upload->data());

        $this->load->view('upload_success', $data);
    }

and my view for form is this:
Code:
<?php echo $error;?>
    <?php echo form_open_multipart('admin/add_thumb');?>
    <input type="file" name="resim" />
    <br />
    <br />
    &lt;input type="submit" value="upload" /&gt;
    &lt;/form&gt;

This codes always returns "You did not select a file to upload." error.

My os is ubuntu 10.04. I tested chromium and firefox. Where am i doing wrong. Can someone help me please.
#2

[eluser]vasily[/eluser]
really in need of help. No opinion about the bug?
#3

[eluser]Flemming[/eluser]
quick guess: your input is called 'resim' but you don't tell your controller.

from the manual:

If you would like to set your own field name simply pass its value to the do_upload function:

$field_name = "some_field_name";
$this->upload->do_upload($field_name);

hope that helps?
#4

[eluser]vasily[/eluser]
thank you for your help. Now it works.




Theme © iAndrew 2016 - Forum software by © MyBB