MultiPartUtility for Image uploading does not work above version 6.0
MultiPartUtility for Image uploading does not work above version 6.0
This is the code for 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);elseshowAlert("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());elsemultipart.addFilePart("uploaded_file", destination,ip_proj_id+"_"+bundle.getString("unit_no")+"_bf"+destination.getName());String response = multipart.finish();System.out.println(response);
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
please share your code along with manifest
– YoLo
Sep 4 '18 at 10:39