0

I try to upload image in codeigniter but i have got
Error : Unknown column 'Array' in 'field

public function do_imageupload(){

    $config['upload_path'] = './imguploads/';
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['max_size'] = '5120';
    $config['max_width']  = '1500';
    $config['max_height']  = '1500';
    $config['overwrite'] = TRUE;
    $config['encrypt_name'] = FALSE;
    $config['remove_spaces'] = TRUE;

    if ( ! is_dir($config['upload_path']) ) die("THE UPLOAD DIRECTORY DOES NOT EXIST");
    $this->load->library('upload', $config);

                if ( ! $this->upload->do_upload('file')) 
                {

                    $arrayName = array( 
                                        'image'=>$this->upload->data()
                                       );

                    $this->Image_model->insert_image($arrayName);// error here 

                } 
                else 
                {
                     echo 'errorrrr';
                }


    }

Error Message: Array to string conversion

how can solve this tell me any suggestion

Error Number: 1054

Unknown column 'Array' in 'field list'

INSERT INTO img_upload (image) VALUES (Array)

1 Answer 1

3

When you are getting image data in the array.

$arrayName = array( 
                   'image'=>$this->upload->data()
                   );

$this->upload->data() // returns an array. 

To get the file name you have to pass a parameter called file_name like $this->upload->data('file_name').

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

Comments

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.