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);
答案 0 :(得分:1)
使用以下
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
并导入
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;