esp32 uploading multipart data to server

Hi guys I am using esp32 as http client to send multipart data which is basically a jpg file stored in spiffs. I need to send this file to server with the following information.

Host: some url
Content-Type: multipart/form-data
Accept: /
Content-Disposition: form-data; name="file"; filename="timestamp.jpg"

I am doing this

file ="/timestamp.jpg");
String debugLogData;

  while (file.available()) {
    debugLogData += char(;


    HTTPClient http;
    http.begin("https://id=some url"); 
    http.addHeader("Content-Disposition", "form-data; name=\"file\"; filename=\"timestamp.jpg\"");
    http.addHeader("Content-Type", "multipart/form-data");             
    http.addHeader("Accept", "*/*");

    int httpResponseCode = http.POST(debugLogData);  


Can anyone suggest something?

You cannot tell the server that you send your request data as multipart/form-data and then just post the complete junk as the only content of the POST.

You have to provide correct MIME parts and use corrrect delimiter headers. It's probably easiest to use a library like this one.

Thanks for providing the library.