Hello i am wanting to upload image from android emulator to asp.net server. The code below can communicate the server. When I tried to create a text file to see the data sent from android was successful or not . But no the file data didn't send across to the server. I tried sending the plain text to the server but the file I created on the server didn't print the text.

The code here:
 HttpURLConnection conn = null;

```
    String boundary = "==============";

        try
        {   
            String disposition = "Content-Disposition: form-data; name=\"userfile\"; filename=\"" + filename + ".jpg\"";
            String contentType = "Content-Type: application/octet-stream";

            String t1   = "Content-Disposition: form-data; name=\"test\";";
            String t2 = "Content-Type: text/plain";

            // This is the standard format for a multipart request
            StringBuffer requestBody = new StringBuffer();
            /*
            requestBody.append("--"+boundary);
            requestBody.append('\n');
            requestBody.append(disposition);
            requestBody.append('\n');
            requestBody.append(contentType);
            requestBody.append('\n');
            requestBody.append('\n');
            requestBody.append(new String(getByteFromStream(stream)));
            */

            requestBody.append('\n');
            requestBody.append('\n');
            requestBody.append("--"+boundary);
            requestBody.append('\n');
            requestBody.append(t1);
            requestBody.append('\n');
            requestBody.append(t2);
            requestBody.append('\n');
            requestBody.append('\n');
            requestBody.append("basdfsdafsadfsad");
            requestBody.append("--"+boundary+"--");

            // Make a connect to the server
            URL url = new URL(targetURL);
            conn = (HttpURLConnection) url.openConnection();

            // Put the authentication details in the request
           /*
             if (username != null) {

                String usernamePassword = username + ":" + password;
                String encodedUsernamePassword = Base64.encodeBytes(usernamePassword.getBytes());
                conn.setRequestProperty ("Authorization", "Basic " + encodedUsernamePassword);
            }
            */
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("MIME-Version:", "1.0");
            conn.setRequestProperty("Content-Type", "multipart/mixed; boundary=" + boundary);

            // Send the body
            DataOutputStream dataOS = new DataOutputStream(conn.getOutputStream());
            dataOS.writeBytes(requestBody.toString());
            dataOS.flush();
            dataOS.close();

            // Ensure we got the HTTP 200 response code
            int responseCode = conn.getResponseCode();
            if (responseCode != 200) {
                throw new Exception(String.format("Received the response code %d from the URL %s", responseCode, url));
            }

```

Is my request body layout not correctly ?