-2
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://mobitracktechnologies.in/imagefiles.php");
StringBody data = new StringBody(textTosend, Charset.forName(HTTP.UTF_8));
MultiPartEntity entity = new MultiPartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
ContentBody cbFile = new FileBody(filePath, "image/jpeg");
entity.addPart("file", cbFile);
entity.addPart("text", data);
httppost.setEntity(entity);
HttpResponse WSresponse = httpclient.execute(httppost);
4

1 回答 1

1

使用以下

 MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

并导入

 import org.apache.http.entity.mime.HttpMultipartMode;
 import org.apache.http.entity.mime.MultipartEntity;
于 2013-11-08T07:50:50.847 回答