简体   繁体   中英

CodeIgniter API Json Server, Missing boundary in multipart/form-data POST data

I use CodeIgniter 3.1.6 I build upload file with the json API. This json for android collaborate data. And I try to test my API code with Postmant for API tester.

And I got error like I write below when I use " Content-Type " " multipart/form-data " in Postman.


: Missing boundary in multipart/form-data POST data in on line :第多部分/表单数据 POST 数据中缺少边界

This is my simple code from my controller .

$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!', );
}

This is my screenshot. Thanks for read my question. I hope you solve my problems.

在此处输入图片说明

在此处输入图片说明

This problem was solved. This is just a simple problem. I should not create content-type manually in a header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM