1. 程式人生 > >http文件傳輸

http文件傳輸

pcl get targe adf load param http set part

上傳端:
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();

http文件傳輸