我正在使用此代码发送图像文件和文本文件..i已经构建了java路径,但仍显示错误

时间:2013-11-08 07:32:30

标签: php android

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);

1 个答案:

答案 0 :(得分:1)

使用以下

 MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

并导入

 import org.apache.http.entity.mime.HttpMultipartMode;
 import org.apache.http.entity.mime.MultipartEntity;