1
votes

I have a form having some textfield and an image upload option where i am able to browse the image and submit the multipartrequest data but my requirement is the user has an option that he may or may not browse the image field at that time how to insert the multipartrequest data with the remaining field.

Below is my code:

MultipartRequest request = new MultipartRequest();
String rootPath=FileSystemStorage.getInstance().getAppHomePath();
String url="some web service url"
if(imagePath!=null && imagePath!=rootPath){
request.setUrl(url);
request.addData("uploadedFile", image.getText(), "image/*");
request.setFilename("uploadedFile", uploadFileName);
request.setPost(true);
request.setFailSilently(true);
NetworkManager.getInstance().addToQueue(request);
request.getResponseData();
}
else{
imagePath=FileSystemStorage.getInstance().getAppHomePath();
request.setUrl(url);
request.addData("uploadedFile", uploadFileName, "image/*");
request.setPost(true);
request.setFailSilently(true);
NetworkManager.getInstance().addToQueue(request);
r.getResponseData();
}

Thanks in Advance.

1

1 Answers

0
votes

You don't have to call addData or setFilename in which case the request will still be a multipart but it will not submit the data.