页面上上传附件 action里面已经拿到MultipartFile文件对象了,但是该怎么通过httpclient传递给远程服务器啊,还有就是 有2个图片流 服务器怎么区分呢? 求大神指点!
如果远程服务器提供接受文件的服务:
[code="java"]//========MultipartEntity
HttpPost post3 = new HttpPost("http://remotehost/post.do");
File upfile = new File("C:\test.jpg");
MultipartEntity entity3 = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));
entity3.addPart("file_name", new StringBody(upfile.getName()));
entity3.addPart("file_contents", new FileBody(upfile));
post3.setEntity(entity3);
new DefaultHttpClient().execute(post3);[/code]