i'm building app to upload image files into server using POST.
After many hours it started to works, but i have last issue. After upload data, my new file have additional header:
--cpPHHy2XlygEWv4fZndlhywQcKPxV33Qn0Z8EOf8^M
Content-Disposition: form-data; name="file"^M
Content-Type: image/jpeg^M
Content-Transfer-Encoding: binary^M
^M
This header doesn't appear in oryginal file.
My upload code is:
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
String urlParam = "http://www.modesa.pl/adminPanel/ajax-tab.php?id_product="+productId+"&id_category=0&token=c4c533d2825f8791a07265d812d62d90&tab=AdminProducts&action=addImage&ajax=1&qqfile=IMG_0599.jpg";
HttpPost httppost = new HttpPost(urlParam);
File file = new File(filename);
MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "image/jpeg");
mpEntity.addPart("IMG_0599", cbFile);
Header[] headers2 = {
new BasicHeader("Cookie", cookieNew),
new BasicHeader("Content-Type", "multipart/form-data")
};
httppost.setEntity(mpEntity);
httppost.setHeaders(headers2);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse responseX = httpclient.execute(httppost);
HttpEntity resEntity = responseX.getEntity();
System.out.println(responseX.getStatusLine());
if (resEntity != null) {
System.out.println(EntityUtils.toString(resEntity));
}
if (resEntity != null) {
resEntity.consumeContent();
}
httpclient.getConnectionManager().shutdown();
Can you help me, what to do, that those headers wont appear in new file ?