How to upload a file along with form data using http.post

You can repeat the exercise on the server side, by logging all request bodies. The result would presumably be different for the app request and the postman request, if what you’re saying so far holds.

Request parameters received on server side:

With postman:

array (
  'title' => 'title 1',
  'description' => 'desc 1',
  'photo' =>
  Symfony\Component\HttpFoundation\File\UploadedFile::__set_state(array(
     'test' => false,
     'originalName' => '40-512.png',
     'mimeType' => 'image/png',
     'size' => 30718,
     'error' => 0,
  )),
)

with ionic:

array (
  'title' => 'title 1',
  'description' => 'desc 1',
  'photo' => 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAKBueIx4ZKCMgoy0qqC+8P//8Nzc8P//////////////////////////////////////////////////////////2wBDAaq0tPDS8P//////////////////////////////////////////////////////////////////////////////wAARCAAPABQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxKRobHBCSMzUvaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwBUAH1oYBhUe+jOaAFzjiimk5ooGf/Z',
)

As you can see, what postman sends is received as a file, but ionic simply sends a string. Are you sure the header should not be set to multipart/form-data for uploading files? (that’s what postman does)

I interpreted your OP when you said this:

save it as a string in base64 format. I need to submit this photo to the server via the same POST request.

…to mean that the server was also supposed to get base64. So the easiest thing to do would seem to be for the server to just treat the photo as a string. If bandwidth is a concern, you could look into ubjson.

hi , how are you used postman in ionic.
i get the same probleme iwantto send data including picture base64 to drupal8