How to send multiple images with form data to API?

#1

How to send multiple images with form data to API?

Actually i want to send branch of image with form data to the server

I have a function there user can upload a post with multiple image with data
like
title
category
and
5 images
how can i do that please help me guys
Any help would be highly appreciated
Thanks

#2

You can try passing the base64 of image to your api like this on your payload,

{
   "title": "Lorem Ipsum",
   "category": "Category One",
   "images": [
     {
         "filename": "987654211",
         "data": "<base64 of image>"
     }
     ...
  ]
}
1 Like
#3

Thanks for your response but how can i create this json array dynamically
please can you tell me .

#4

The way I can solve this is, First I will create a form for title and category. And next I’ll add a button which leads to take picture from camera or gallery then after taking the picture I’ll save the base64 of image to an array. Then if your want another picture just click the button again and the process will repeat it. After doiing so you can create an object where you can put the form data and the images array together

1 Like
#5

Yes i understand please could you send me your code . I request you.
Thanks