我想使用Codeigniter使用REST API将一些图像上传到服务器。
但是在上传图像/刷新此表上的phpmyadmin后,我遇到了问题。
我知道这个问题很经典,我已经要做的事情:
但没有任何改变,在我刷新页面phpmyadmin时,始终会出现此错误。
我怎么了?
谢谢
如果您由于我的代码Rest-API而认为我的错误,这是我的代码:
控制器:
public function upload_post()
{
// $config['max_size'] = '100';
// $config['max_width'] = '1024';
// $config['max_height'] = '768';
$msgCreated = ['status' => true, 'message' => 'Image Has Been Upload'];
$msgFailCreated = ['status' => false, 'message' => 'Failed to Upload Image !'];
$config['upload_path'] = './image/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload('file')) {
$this->set_response($msgFailCreated, 404);
} else {
$info = $this->upload->data();
$image_path = base_url("image/" . $info['raw_name'] . $info['file_ext']);
$data = [
"name_image" => $this->input->post('name_image'),
"image" => $image_path
];
if ($this->mahasiswa->insertImage($data)) {
$this->set_response($msgCreated, 201);
} else {
$this->set_response($msgFailCreated, 400);
}
}
}
型号:
//? Membuat Upload Image
public function insertImage($data){
return $this->db->insert('image', $data);
}