Search code examples
phprestapicodeignitercodeigniter-3

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.


Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0

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.

enter image description here

enter image description here


Solution

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