图片上传但出现错误:codeigniter中“字段列表”中的未知列“ Array”

时间:2019-10-10 08:43:47

标签: codeigniter

我尝试在codeigniter中上传图片,但是我已经
错误:“字段

中的未知列“数组”
CarComponent

错误消息:数组到字符串的转换

如何解决这个问题,告诉我任何建议

错误号:1054

“字段列表”中的未知列“数组”

将{INSERT INTO DaggerMagicBox.create().poke(this)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'; } } )值(数组)

1 个答案:

答案 0 :(得分:3)

在阵列中获取图像数据时。

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

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

要获取文件名,您必须传递一个名为file_name的参数,例如$this->upload->data('file_name')