Bild auf den Server hochladen

Ich habe viel gegoogelt, aber es funktioniert nicht. Ich habe viele Websites mit Informationen gefunden, aber auf allen Websites ist meine App abgestürzt. Das Bild, das ich öffnen möchte, ist: "lastfile.png". Es wird im internen Speicher gespeichert, also öffne ich es mit openFileInput ("lastfile.png");

Ich mache es in einer AsyncTask.

Das ist mein Code bis jetzt:

class PostTask extends AsyncTask<String, String, String>{
        @Override
        protected String doInBackground(String... uri) {
            if(picture == null) {
                HttpClient httpclient = new DefaultHttpClient();
                HttpResponse response;
                String responseString = null;
                try {
                    response = httpclient.execute(new HttpGet(uri[0]));
                    StatusLine statusLine = response.getStatusLine();
                    if(statusLine.getStatusCode() == HttpStatus.SC_OK){
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        response.getEntity().writeTo(out);
                        out.close();
                        responseString = out.toString();
                    } else{
                        response.getEntity().getContent().close();
                        throw new IOException(statusLine.getReasonPhrase());
                    }
                } catch (ClientProtocolException e) {
                    Toast.makeText(AddStoryActivity.this, getResources().getString(R.string.error), Toast.LENGTH_LONG).show();
                    e.printStackTrace();
                } catch (IOException e) {
                    Toast.makeText(AddStoryActivity.this, getResources().getString(R.string.error), Toast.LENGTH_LONG).show();
                    e.printStackTrace();
                }
                return responseString;
            } else {
                /* IMAGE UPLOAD */
            }
            return "";
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            progress.cancel();
            Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();       
        }


    }

Antworten auf die Frage(2)

Ihre Antwort auf die Frage