I am setting headers and body , Using fetch with Post to upload image on server.I am getting the response code 200 but it is not uploading image but rest of the Data is getting uploaded.
Here is the code of body:
export default function setRequestBody(imagePath){ let boundry = "----WebKitFormBoundaryIOASRrUAgzuadr8l"; let body = new FormData(); body.append("--"+boundry+"\r\n"); body.append("Content-Disposition: form-data; name=imageCaption\r\n\r\n"); body.append("Caption"+"\r\n"); body.append("--"+boundry+"\r\n"); body.append("Content-Disposition: form-data; name=imageFormKey; filename =iimageName.pngg \r\n"); body.append("Content-Type: image/png \r\n\r\n"); body.append({uri : imagePath}); // appened image Data Here body.append("\r\n"); body.append("--"+boundry+"--\r\n"); return body}
Please help.What mistake I am making. :(