0

Currently have these code.

    $config['upload_path'] = './uploads/';
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size'] = '1000';
                $config['max_width']  = '270';
                $config['max_height']  = '280';
$this->load->library('upload', $config);

Then ill insert the details into the database.

$this->Model->upload_image($this->upload->data(),$result_id);

But the db row is empty so i checked myself. I print_r($image_data) which is the first parameter of the model function. Still empty, to make sure even mor. i typed in.

print_r($this->upload->data());

Still, the results come out empty.

Array ( [file_name] => [file_type] => [file_path] => ./uploads/ [full_path] => ./uploads/ [raw_name] => [orig_name] => [client_name] => [file_ext] => [file_size] => [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => )

EDIT:

if ( ! $this->upload->do_upload())
            {
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('view', $error);
            }
            else
            {
            $image_data = array('upload_data' => $this->upload->data());
            print_r($this->upload->data());
}
6
  • 1
    Did you run $this->upload->do_upload()? Commented Feb 28, 2014 at 19:41
  • I added the do_upload() line of code, although it wont print_r.... Btw, do i need to namem y function do_upload aswell? Commented Mar 1, 2014 at 0:31
  • Can you include the view that has the form in your question? Commented Mar 1, 2014 at 0:42
  • I just did, on the edit. Commented Mar 1, 2014 at 0:43
  • 2
    Check if form is multipart. Commented Mar 1, 2014 at 4:39

1 Answer 1

1

If you have given any name to your input file control than you must need to set it while using this do_upload function.

For e.g.

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

By default the upload routine expects the file to come from a form field called userfile, and the form must be a "multipart type

see the reference $this->upload->do_upload()

http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html

under the Function Reference in above link

Sign up to request clarification or add additional context in comments.

1 Comment

I was waiting for samutz to post an answer. Ill just accept yours. Thanks for answering!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.