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.