0

Error:

E/JSON Parser: Error parsing data org.json.JSONException: End of input at character 0 of

I have to send image to server with post method but I cant send. Json came to me null. There is my code:

if (method.equalsIgnoreCase("POST")) {
            URL url_ = new URL(url);

            String paramString = URLEncodedUtils.format(params, "utf-8"); // unused

            HttpURLConnection httpConnection = (HttpURLConnection) url_.openConnection();
            httpConnection.setReadTimeout(10000);
            httpConnection.setConnectTimeout(15000);
            httpConnection.setRequestMethod("POST");
            httpConnection.setDoInput(true);
            httpConnection.setDoOutput(true);

            InputStream in = httpConnection.getInputStream();
            OutputStream out = new FileOutputStream(picturePath);
            copy(in, out);
            out.flush();
            out.close();

            httpConnection.connect();

            //Read 2
            BufferedReader br = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
            String line2 = null;
            StringBuilder sb = new StringBuilder();
            while ((line2 = br.readLine()) != null) {
                sb.append(line2);
            }
            br.close();
            json = sb.toString();


        }

How can I send image to server? Thanks..

Hilalkah
  • 945
  • 15
  • 37

0 Answers0