0
나는 어떤 예외가 있다면 파일에 기록 할 안드로이드 응용 프로그램을 가지고 있습니다. (파일은 장치의 내부 메모리에 저장됩니다.) ..... 이제 알고 싶습니다. 이 파일을 내 localhost 서버에 보낼 수 있습니다. 사전에안드로이드 - 서버에 텍스트 파일 보내기
감사
편집 : 아래의 코드는
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Bitmap bm=bitmap;
bm.compress(CompressFormat.PNG, 75, bos);
byte[] data = bos.toByteArray();
HttpClient httpClient = new DefaultHttpClient();
String url="192.168.1.1**";
HttpPost postRequest = new HttpPost(url+"uploadimage");
ByteArrayBody bab = new ByteArrayBody(data, imageName);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("uploadfile", bab);
//reqEntity.addPart("photoCaption", new StringBody("sfsdfsdf"));
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
s = s.append(sResponse);
}
System.out.println("Response: " + s);
} catch (Exception e) {
// handle exception here
Log.e(e.getClass().getName(), e.getMessage());
}
유사 내가 파일 (텍스트 파일)을 업로드 할 ... 내가 이미지를 업로드하는 데 사용하는 것입니다.
서버의 코드는 무엇입니까? –