图像无法上传Codeigniter

时间:2016-07-26 10:20:01

标签: php codeigniter

我的图片上传出现以下错误

Array ( [error] =>
You did not select a file to upload.

)

这是html

<div class="form-group">
  <label class="col-sm-3 control-label">Product Image</label>
  <div class="col-sm-9">
    <input type="file" name="item_image" />
  </div>
</div>

这是控制器

$config['upload_path'] = './images/item_images';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$error = '';
$udata = '';
$this->load->library('upload');
$this->upload->initialize($config);

if (!$this->upload->do_upload('item_image')) {
  $error = array('error' => $this->upload->display_errors());
  print_r($error);
} else {
  $udata = array('upload_data' => $this->upload->data());
  print_r($udata);
  $item_data['image_url'] = "images/item_images/" . $udata['upload_data']['file_name'];
}

我无法解决我的错误

0 个答案:

没有答案