Question: How do I attach a file to the
HTTP POST request? I am using URLConnection to send the HTTP request.
Answer: you need to write code like this.
Please find exact details yourself 
URL dest = "http://www.myurlhere.com ";
URLConnection urlCon = dest.openConnection();
// prepare input and output
urlCon.setDoInput(true);
urlCon.setDoOutput(true);
// Disable caching
urlCon.setUseCaches(false);
// Post output
DataOutputStream out =
new DataOutputStream(urlCon.getOutputStream());
out.writeBytes( file.toString );
out.flush();
out.close();
// return servlet response as a DataInputStream
DataInputStream in = new DataInputStream(urlCon.getInputStream());
// and so on
....
***************************************
Our older tips: March 22, 2001 - October 21, 2002
read here.
All published and not published on site tips you can find
here
103 comments | | Score: 1.5
|