CodeIgniter API Json Server,多部分/表单数据POST数据中缺少边界

时间:2018-02-16 14:40:28

标签: php rest api codeigniter codeigniter-3

我使用 CodeIgniter 3.1.6 我用json API构建上传文件。这个json for android协作数据。我尝试使用 Postmant 为API测试人员测试我的API代码。

当我使用" Content-Type" " multipart/form-data"在邮递员。

  


      警告:在multipart / form-data POST数据中缺少边界       未知在线        0 的       

这是我的控制器中的简单代码。

$config['upload_path'] = './foto_galeri/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '0';
$config['remove_spaces'] = TRUE;                

$this->load->library('upload', $config);

$field_name = 'foto';
if ($this->upload->do_upload($field_name)) {
    $image_name = $this->upload->data();
    $data = array(
      'wisata_idwisata' => $this->input->post('idwisata'),
      'wisata_foto' => $image_name['file_name']
    );
    $this->M_wisata_foto->create($data);
    $output = array( 'status' => 200,'message' => 'Create success!', );
    json_output(200,$output);
    }
else
{
    $output = array(
        'status' => 500,'message' => 'Internal Error null condition!', );
}

这是我的截图。 感谢您阅读我的问题。我希望你能解决我的问题。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

感谢您查看和推荐我的问题。 这个问题解决了。 这只是一个简单的问题。我不应该在标题中手动创建内容类型。