Hi I am uploadingfile to php server.For this we require to send string parameter .I am using following code for uploading.So is there any tutorial that set parameter or any explanation that describes setting .thanks
url = new URL(httpPath);
connection = (HttpURLConnection) url.openConnection();
// Allow Inputs & Outputs
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
// Enable POST method
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Content-Type",
"multipart/form-data;boundary=" + boundary);
outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(twoHyphens + boundary + lineEnd);
Don’t reinvent the wheel. Use Apache HttpClient. Read this javadoc page for an example of a post containing a file upload and a string parameter: