这是multipartUtility的代码:-
@Override protected String doInBackground(String... strings) {try {MultiPartUtility multipart = new MultiPartUtility( requestURL, "UTF-8");
for (String fileName : selectedFilePaths.split(",")) {try{// File uploadFile=new File(fileName);destination=new File(fileName); if (destination.canRead()) {
long fileSizeInBytes = destination.length();float fileSizeInKB = fileSizeInBytes / 1024;// Convert the KB to MegaBytes (1 MB = 1024 KBytes)
float fileSizeInMB = fileSizeInKB / 1024;String calString=Float.toString(fileSizeInMB);}else{showAlert("cannot read file",-1);}
} catch (Exception e) {e.printStackTrace }String ip_proj_id=bundle.getString("ipProjectId");String chq="";multipart.addFormField("username",SessionClass.getUserFname(getActivity()));multipart.addFormField("password",SessionClass.getPass(getActivity()));
multipart.addFormField("url",url);multipart.addFormField("jsonParam",String.valueOf(jObjBook));for(int i=0;i<selectedFilePaths.split(",").length;i++){int pos=i+1;if(status==0){chq="ch"+pos;multipart.addFilePart("uploaded_file[]", destination,ip_proj_id+"_"+bundle.getString("unit_no")+"_"+chq+destination.getName());}else{multipart.addFilePart("uploaded_file[]", destination,ip_proj_id+"_"+bundle.getString("unit_no")+"_bf"+destination.getName());}}String response = multipart.finish();System.out.println(response);