http文件传输
上传端:
File uploadFile =new File(); PostMethod mPost = null; try{ String targetURL ="; HttpClient client = new HttpClient(); mPost = new PostMethod(targetURL); Part [] part = {new FilePart(uploadFile.getName(), uploadFile)}; mPost.setRequestEntity(new MultipartRequestEntity(part,mPost.getParams())); mPost.setRequestHeader("cookies", ""); client.executeMethod(mPost); if(mPost.getStatusCode()==200){ }
}
接受端:
使用
DiskFileItemFactory factory = new DiskFileItemFactory();