how to send parameters with file in android
<p>I am uploading image in android. Currently my code only uploads file but I also want to send some parameter. I am trying following</p>

<pre><code>FileInputStream fileInputStream = new FileInputStream(sourceFile);
        URL url = new URL(upLoadServerUri);
        conn = (HttpURLConnection) url.openConnection(); // Open a HTTP  connection to  the URL
        conn.setDoInput(true); // Allow Inputs
        conn.setDoOutput(true); // Allow Outputs
        conn.setUseCaches(false); // Don't use a Cached Copy
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.setRequestProperty("ENCTYPE", "multipart/form-data");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
        conn.setRequestProperty("uploaded_file", fileName);
        dos = new DataOutputStream(conn.getOutputStream());

        dos.writeBytes(twoHyphens + boundary + lineEnd);
        dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";filename=\""+ fileName + "\"" + lineEnd);
        dos.writeBytes(lineEnd);

        //Sending data
        dos.writeBytes(twoHyphens + boundary + lineEnd);
        dos.writeBytes("Content-Disposition: form-data; name=\"paramName\"" + lineEnd);
        dos.writeBytes(lineEnd);
        dos.writeBytes(globalUID);
</code></pre>

<p>and on the server side I am using php. here is how I am trying to get that parameter</p>

<pre><code>$param = $_POST["paramName"];
target_path1 = "./places_photos/" . $param;
</code></pre>

<p>But my current code does upload file but it does not send parameters. How can I send parameters and how can I get them on server side?</p>

<p><strong>Update</strong></p>

<p>Currently, the image is saved in <code>places_photos</code> directory which is mentioned in <code>$target_path1</code> variable. What I want is to save that image in user's directory and that directory is named as user id. But unfortunately I am not getting userid on server side. How can I send userid to server along with file?</p>
