Send a jpg image through a POST request

I'm trying to send a jpg image using POST

Until now I was able to read the image byte by byte.

I try to send the image in this way but I don't know if the server receive succesfully the image:

client.connect(host, 80);
client.println("POST "+String(api_page)+" HTTP/1.1");
client.println("Host: " + String(host));
client.println("Content-Type: image/jpeg");
client.println("Content-Transfer-Encoding: binary");
client.print("Content-Length: ");
client.println(length);
client.println();

//now I write the image as a set of byte
while(...) {
client.write(byte_buffer, byte_buffer_length);
}

I've a php server, how can I know if the server has received the image?

I've a php server, how can I know if the server has received the image?

Take a look at the return code in the server's response. If the server application is written conforming to standards a result code in the 2xx range marks a success. A 5xx result code marks an error on the server side, while a 4xx result code usually means the client did something wrong. 3xx result codes show the client that it has to react, in your case you've probably chosen the wrong URL.