0
我正在使用MIME多部分上傳圖像到服務器。有時圖像會變形。如何解決這個問題? 注:扭曲的手段,一些像素丟失。 我使用下面的代碼上傳:圖像在上傳時被扭曲
File file = new File(filePath[0]);
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost("serverurl");
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("Content-Type",new StringBody("multipart/form-data;charset=utf-8"));
entity.addPart("Content-Length", new StringBody(String.valueOf(file.length())));
entity.addPart("UploadContentPostD", new FileBody(file));
entity.addPart("DocumentName", new StringBody(file.getName()));
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost,localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
圖像失真是:
請準確解釋你的意思是扭曲?不良的像素/畫面比例改變/像素損壞? – Elemental 2011-12-14 14:25:11
像素丟失,所以圖像看起來像重疊其他部分 – Sandy 2011-12-14 14:27:24