Codeigniter 代码点火器:我能’;t在数据库中插入文件名图像

Codeigniter 代码点火器:我能’;t在数据库中插入文件名图像,codeigniter,Codeigniter,这是我的控制器中的代码…我无法在数据库中插入图像的名称,只能在目录中上载/上载/ 插入图像文件名的代码如下:$data['file\u name']=$\u POST['file\u name'] 请帮帮我,因为我需要你快点。。多谢各位 public function edit ($id = NULL) { // Fetch a article or set a new one if ($id) { $this->data[‘article’] = $this->ar

这是我的控制器中的代码…我无法在数据库中插入图像的名称,只能在目录中上载/上载/

插入图像文件名的代码如下:
$data['file\u name']=$\u POST['file\u name']

请帮帮我,因为我需要你快点。。多谢各位

public function edit ($id = NULL)
{


  // Fetch a article or set a new one
  if ($id) {
  $this->data[‘article’] = $this->article_m->get($id);
  count($this->data[‘article’]) || $this->data[‘errors’][] = ‘article could not be found’;
  }
  else {
  $this->data[‘article’] = $this->article_m->get_new();
  }

  // Set up the form
  $rules = $this->article_m->rules;
  $this->form_validation->set_rules($rules);

  // Process the form

  if ($this->form_validation->run() == TRUE) {

  $data = $this->article_m->array_from_post(array(
  ‘cat_id’,
  ‘title’, 
  ‘url’, 
  ‘body’, 
  ‘pubdate’
  ));


  /*
    * upload
    */
  $config[‘upload_path’] = ‘c:/wamp/www/uploads/’;
  $config[‘allowed_types’] = ‘gif|jpg|png’;
  $config[‘max_size’] = ‘1000’;
  $config[‘max_width’]  = ‘10240’;
  $config[‘max_height’]  = ‘7680’;
  $field_name = “file_name”;
  $this->load->library(‘upload’, $config);
  if( $this->upload->do_upload($field_name)){
    print “uploaded”;
    die(“uploaded”);

  } else {
    $error = array(‘error’ => $this->upload->display_errors());
    print_r($error);
    die();
  }

  //end of upload
  //insert file_name 
                    $data[‘file_name’] = $_POST[‘file_name’];
  $this->article_m->save($data, $id);

  } 
  // Load the view
  $this->data[‘subview’] = ‘admin/article/edit’;
  $this->load->view(‘admin/_layout_main’, $this->data);
}

你可以试试这样的

if( $this->upload->do_upload($field_name) )
{
    // get upload data
    $upload_data = $this->upload->data();
    $data[‘file_name’] = $upload_data['file_name'];
    $this->article_m->save($data, $id);
    //...
}
else
{
    //...
}