안드로이드 이미지 업로드 (Android To Web)

안드로이드에서 Web 으로 이미지 업로드 하는 방법입니다.
단순히 SD Card 에 있는 이미지 하나를  웹에 올리는 프로그램이라
개념 잡는 용도로 보시면 됩니다.

<android>
1) sdcard 에 샘플 이미지를 올려놓는다.
     (adb push 이용하여 업로드)
     /sdcard/f1.jpg
2) 소스코드 수정
String mFilePath = "/sdcard/f1.jpg";   (변경해주세요)

<web >
1)  업로드를 담당하는 클라이언트
     http://www.inculab.net/upload.php

2) 업로드 된 파일경로
 http://www.inculab.net/files/


업로드를 하면 아래와 같이 성공 유무를 노출해줍니다.
http://www.inculab.net/files/f1_2010-02-10_18_33_40.jpg



사용자 삽입 이미지


소스코드 다운로드

Posted by Tcher

2010/02/10 18:45 2010/02/10 18:45
, , ,
Response
35 Trackbacks , 30 Comments
RSS :
http://blog.inculab.net/rss/response/28

Trackback URL : http://blog.inculab.net/trackback/28

Trackbacks List

  1. 시스의 생각

    Tracked from oooooxo's me2DAY 2010/10/30 23:51 Delete

    안드로이드 업로드-JSP 다운로드 구현 안드로이드 이미지 업로드 (Android To Web) MultipartRequest를 이용하여 업로드구현하기 값 전달은 도저히 안되서 그냥 Get방식으로 때려버렸다 ㅋ 일단 구현했으니 만세만세

  2. Fall wedding flowers.

    Tracked from Fall wedding flowers. 2011/03/10 07:44 Delete

    Fall wedding flowers.

  3. Torture.

    Tracked from Pussy torture. 2011/03/10 08:54 Delete

    Torture. Cock and ball torture stories. Torture methods.

  4. Bdsm torture stories.

    Tracked from Bdsm torture stories. 2011/03/10 19:22 Delete

    Bdsm torture stories.

  5. Bdsm torture stories.

    Tracked from Bdsm stories nc torture free site. 2011/03/11 08:26 Delete

    Rape torture bdsm stories. Bdsm torture stories.

  6. Garden flowers.

    Tracked from Butterfly garden flowers. 2011/03/11 20:04 Delete

    Garden flowers yellow. Yellow color scheme garden flowers. Garden flowers. Encyclopedia of garden flowers.

  7. Cock and ball torture ideas.

    Tracked from Cock torture. 2011/03/12 09:27 Delete

    Cock torture. Huge cock tit torture.

  8. Tickle torture.

    Tracked from Tickle torture. 2011/03/12 23:48 Delete

    Tickle torture.

  9. Forget me not flowers.

    Tracked from Forget me not flowers. 2011/03/13 10:34 Delete

    Forget me not flowers. Forget me nots flowers.

  10. Tit torture.

    Tracked from Tit torture. 2011/03/13 22:32 Delete

    Tit torture.

  11. Fall wedding flowers.

    Tracked from Fall wedding flowers. 2011/03/14 11:59 Delete

    Fall wedding flowers.

  12. Greasemonkey downloading from youtube.

    Tracked from Downloading videos from youtube. 2011/03/15 02:05 Delete

    Downloading files from youtube. Downloading videos from youtube. Downloading video from youtube. Downloading from youtube.

  13. Wooden pony riding cock torture.

    Tracked from Cock and ball torture. 2011/03/15 04:26 Delete

    Cock torture. Brutal cock torture. Cock and ball torture stories. Male torture cock ball bondage. Cock and ball torture. Adult cock and ball torture. Cock ball torture.

  14. Tickling torture links.

    Tracked from Tickling torture links. 2011/03/15 19:37 Delete

    Tickling torture links.

  15. Torture cartoons.

    Tracked from Torture cartoons. 2011/03/15 20:51 Delete

    Tickle torture cartoons. Torture cartoons.

  16. Torture stories.

    Tracked from Torture stories. 2011/03/17 03:05 Delete

    Torture stories.

  17. Male torture cock ball bondage.

    Tracked from Bondage torture. 2011/03/17 05:00 Delete

    Self bondage torture stories.

  18. Wedding fall flowers.

    Tracked from Fall flowers. 2011/03/17 18:03 Delete

    Wedding fall flowers. Fall wedding 2007 flowers. Fall bridal flowers. Planting fall flowers. Fall flowers for wedding. Fall wedding flowers. Fall flowers.

  19. Bondage torture.

    Tracked from Bondage torture. 2011/03/18 15:06 Delete

    Bondage torture.

  20. Tit torture.

    Tracked from Tit torture. 2011/03/18 20:00 Delete

    Tit torture.

  21. Downloader youtube.

    Tracked from Downloader youtube. 2011/03/19 19:04 Delete

    Downloader youtube.

  22. Autumn wedding flowers.

    Tracked from Autumn wedding flowers. 2011/03/20 12:50 Delete

    Autumn wedding flowers.

  23. Can i download youtube to pc.

    Tracked from Download youtube videos to pc. 2011/03/21 03:44 Delete

    Download youtube video to your pc. Download youtube to pc.

  24. Download videos from youtube.

    Tracked from Downthisvideo download videos from youtube googlevideo. 2011/03/21 04:49 Delete

    Downloading videos from youtube. Download videos from youtube probram. Download videos from youtube internet explorer. Download videos from youtube. Downthisvideo download videos from youtube googlevideo.

  25. Torture rack inquisition.

    Tracked from Torture rack computer server christ. 2011/03/21 13:20 Delete

    Torture rack girls.

  26. Download youtube to my ipod free.

    Tracked from Download youtube to my ipod free. 2011/03/22 03:51 Delete

    Download youtube to my ipod free.

  27. Download youtube to my ipod free.

    Tracked from Download youtube to my ipod free. 2011/03/22 18:22 Delete

    Download youtube to my ipod free.

  28. Download youtube to my ipod free.

    Tracked from Download youtube to my ipod free. 2011/03/24 07:56 Delete

    Download youtube to my ipod free.

  29. Automatic youtube downloader.

    Tracked from Free youtube video downloader and converter. 2011/03/25 07:26 Delete

    Best youtube video downloader.

  30. Download youtube to my ipod free.

    Tracked from Download youtube to my ipod free. 2011/03/25 17:00 Delete

    Download youtube to my ipod free.

  31. Mp3 files video download internet media youtube.

    Tracked from Mp3 files video download internet media youtube. 2011/03/26 07:51 Delete

    Download youtube files. Mp3 files video download internet media youtube.

  32. Downloading youtube videos.

    Tracked from Downloading youtube videos. 2011/03/27 08:43 Delete

    Downloading videos from youtube. Downloading youtube videos.

  33. Can i download youtube to pc.

    Tracked from Download youtube to pc. 2011/03/28 07:20 Delete

    Download youtube to pc.

  34. Free download book hungry girl 300 under 300.

    Tracked from Free download book hungry girl 300 under 300. 2011/07/15 05:53 Delete

    Free download book hungry girl 300 under 300.

  35. Lipitor unusual side effect.

    Tracked from Lipitor. 2011/07/16 12:57 Delete

    Lipitor.

Comments List

  1. 성신여대 2010/03/12 18:49 # M/D Reply Permalink

    jsp를 이용해서 웹을 구축한경우는 어떻게 해야할까요?

    1. Tcher 2010/03/12 19:30 # M/D Permalink

      JSP 도 마찬가지입니다.
      JSP 도 값을 받아서 저장하는 거라
      JSP 문법에 맞게 개발하면 됩니다.

      JSP 문법을 잘 몰라서 코드까지는 못 올리네요^^

  2. 지나 2010/05/04 14:54 # M/D Reply Permalink

    안녕하세요 질문이 있는데요.
    안드로이드를 공부하고 있는 학생입니다.

    음악에 사용되는 오선지 그림파일을 안드로이드 화면에 띄우고 싶은데..
    어떻게 업로드 시켜야 될까요??

    오선지 파일이 컴퓨터에 저장되있을 경우..
    그 그림을 안드로이드 화면에 출력시킬 방법좀 알려주세요^^
    ji-na68@hanmail.net으로 답변 부탁드립니다...

    1. Tcher 2010/05/12 09:52 # M/D Permalink

      이미지는 리소스의 이미지 디렉토리에 넣으신 후
      안드로이드에서 R.drawable.xxxx 이런 형태로 불러다 사용할 수 있습니다.~
      메일로 공유해드리죠~

  3. parkzel 2010/07/16 10:56 # M/D Reply Permalink

    정말 좋은 소스 감사드립니다.

    근대 제가 test를 해볼려고 하는데..
    while (bytesRead > 0) {
    dos.write(buffer, 0, bufferSize);
    bytesAvailable = mFileInputStream.available();
    bufferSize = Math.min(bytesAvailable, maxBufferSize);
    bytesRead = mFileInputStream.read(buffer, 0, bufferSize);
    }

    의 dos.write(buffer, 0, bufferSize); 코드 부분에서 에러가 나더라구요.
    이부분을 처음 다루는 거라 부족한게 많아 해결이 어렵네요.ㅠㅠ

  4. parkzel 2010/07/16 17:38 # M/D Reply Permalink

    07-16 07:48:49.707: INFO/ARMAssembler(54): generated scanline__00000077:03010104_00000004_00000000 [ 22 ipp] (41 ins) at [0x47b1a0:0x47b244] in 10667781 ns
    07-16 07:48:55.727: DEBUG/dalvikvm(114): GC freed 160 objects / 7048 bytes in 145ms
    07-16 07:49:05.378: DEBUG/dalvikvm(15028): GC freed 977 objects / 184784 bytes in 120ms
    07-16 07:49:05.556: DEBUG/dalvikvm(15028): GC freed 206 objects / 138120 bytes in 85ms
    07-16 07:49:05.566: INFO/dalvikvm-heap(15028): Grow heap (frag case) to 4.259MB for 522438-byte allocation
    07-16 07:49:05.708: DEBUG/dalvikvm(15028): GC freed 0 objects / 0 bytes in 123ms
    07-16 07:49:05.936: DEBUG/dalvikvm(15028): GC freed 44 objects / 261944 bytes in 89ms
    07-16 07:49:05.986: INFO/dalvikvm-heap(15028): Grow heap (frag case) to 5.008MB for 1046726-byte allocation
    07-16 07:49:06.136: DEBUG/dalvikvm(15028): GC freed 0 objects / 0 bytes in 135ms
    07-16 07:49:06.406: DEBUG/dalvikvm(15028): GC freed 3 objects / 522496 bytes in 97ms
    07-16 07:49:06.486: INFO/dalvikvm-heap(15028): Grow heap (frag case) to 6.508MB for 2095302-byte allocation
    07-16 07:49:06.636: DEBUG/dalvikvm(15028): GC freed 0 objects / 0 bytes in 143ms
    07-16 07:49:07.096: DEBUG/dalvikvm(15028): GC freed 3 objects / 1046784 bytes in 93ms
    07-16 07:49:07.317: INFO/dalvikvm-heap(15028): Grow heap (frag case) to 9.508MB for 4192454-byte allocation
    07-16 07:49:07.546: DEBUG/dalvikvm(15028): GC freed 0 objects / 0 bytes in 209ms
    07-16 07:49:08.337: DEBUG/dalvikvm(15028): GC freed 3 objects / 2095360 bytes in 98ms
    07-16 07:49:08.347: INFO/dalvikvm-heap(15028): Forcing collection of SoftReferences for 8386758-byte allocation
    07-16 07:49:08.476: DEBUG/dalvikvm(15028): GC freed 0 objects / 0 bytes in 122ms
    07-16 07:49:08.486: ERROR/dalvikvm-heap(15028): Out of memory on a 8386758-byte allocation.

    ............
    ............

    07-16 07:49:08.697: ERROR/AndroidRuntime(15028): Uncaught handler: thread main exiting due to uncaught exception
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): java.lang.OutOfMemoryError
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:93)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:218)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$HttpOutputStream.write(HttpURLConnection.java:647)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at java.io.DataOutputStream.write(DataOutputStream.java:101)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at hj.UploadTest.UploadTest.HttpFileUpload(UploadTest.java:94)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at hj.UploadTest.UploadTest.DoFileUpload(UploadTest.java:55)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at hj.UploadTest.UploadTest.access$1(UploadTest.java:53)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at hj.UploadTest.UploadTest$1.onClick(UploadTest.java:44)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.View.performClick(View.java:2364)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.View.onTouchEvent(View.java:4179)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.widget.TextView.onTouchEvent(TextView.java:6540)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.View.dispatchTouchEvent(View.java:3709)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.os.Handler.dispatchMessage(Handler.java:99)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.os.Looper.loop(Looper.java:123)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at android.app.ActivityThread.main(ActivityThread.java:4363)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at java.lang.reflect.Method.invokeNative(Native Method)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at java.lang.reflect.Method.invoke(Method.java:521)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    07-16 07:49:08.747: ERROR/AndroidRuntime(15028): at dalvik.system.NativeStart.main(Native Method)


    ---------------------------------------------------------------
    07-16 07:49:08.486: ERROR/dalvikvm-heap(15028): Out of memory on a 8386758-byte allocation.

    이런 에러 이후에 exception이 발생합니다.

    용량이 작은 파일로 했더니 잘 동작을 합니다.
    사진 같은 큰 용량의 DATA는 어떻게 처리를
    해야 되는지요.

    또한 제가 지금 ASP로 작성을 해야되는데.
    안드로이드 소스가 바뀌는 부분이 있는지요.

    1. Tcher 2010/07/16 18:24 # M/D Permalink

      Out of memory on a 8386758-byte allocation. 메모리 문제네요.
      이미지가 큰 경우 줄여주는 작업을 하셔야합니다.
      실제 이미지가 크면 3G망으로 올릴 경우 수십초~ 수분은 걸립니다.
      가능하면 150kbyte 언더로 줄이시는게 좋습니다.

      이미지를 불러와서 Bitmap.Option 이런걸 통해
      encoding 을 하시면 줄일 수 있습니다.

      관련해서는 Bitmap 부분을 살펴보시면 됩니다. ^^

  5. JW 2010/07/21 17:15 # M/D Reply Permalink

    똑같이 돌려봣는데 안되는데 ㅜㅜ
    왜 그런지 잘 모르겟습니다 .ㅜㅜ
    php파일을 서버에 그냥 업로드 시켜놓으면 되는건가여???

    지금 몇일째 하고 있는데 안됩니다 ㅜㅜ
    아무것도 안고치고 url과 filepath만 고쳤는데 ........

    좀 도와주세요 ㅜㅜ

    1. Tcher 2010/07/22 15:34 # M/D Permalink

      php 는 버전이나 환경에 따라 달리 동작할 수 있습니다.
      일단 php 가 정상적으로 동작하는지 테스트하셔야합니다.
      upload_form.php 같은걸 만들어서 제가 올려둔 upload.php 로 파일업로드를 해보세요. 그렇게해서 정상적으로 파일이 업로드되면 그 이후에 안드로이드에서 테스트하셔야 합니다.

      아니면 http://www.inuclab.net/upload.php 로 url 변경하시고
      확인은 http://www.inculab.net/files/업로드된파일명 으로 하셔도 됩니다.

  6. JW 2010/07/23 13:50 # M/D Reply Permalink

    네 감사합니다.
    파일로 된 이미지를 웹에 업로드하는 것까지는 완료하였습니다.
    근데 비트맵으로 된 이미지를 업로드 할려고 하니 ....
    많이 바뀌는 부분이 많습니다 ㅜㅜ
    비트맵을 파일로 바꿔서 업로드 하는 방법을 택해야 할까요?

  7. tea 2010/07/27 17:51 # M/D Reply Permalink

    dos.writeBytes(twoHyphens + boundary + lineEnd);
    dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + fileName+"\"" + lineEnd);
    dos.writeBytes(lineEnd);
    이것의 의미에 대해 가르쳐 주십시오.

    1. metoo 2011/03/16 18:19 # M/D Permalink

      저도 이게 궁금해요;;
      어떤걸 나타내는거죠?

  8. Justin 2010/08/19 00:46 # M/D Reply Permalink

    안냐세여
    따라서해봤는데요
    밑에 같은 에러가뜨거든요...
    이거 퍼미션 어디서 줘야되나요???
    java.security.AccessControlException access denied (java.io.filepermission /base/data/home/apps/jungootesting/1.344173076716508206/WEB-INF/upload write)
    저는 서버를 아파치안쓰구요 구글 앱 엔진쓰거든요
    아무래도 서버에 write하는 퍼미션이 안들어간거같은데
    어떻게 퍼미션주는지 모르겠네요 ㅠ

    1. Justin 2010/08/19 01:13 # M/D Permalink

      아.. 구글 앱 엔진은 printwriter나 FileOutputStream이런거 허가안하네요 ... 아젠장 제약이 너무많아 구글 앱 엔진 ㅠ

  9. 초짜안돌 2010/09/07 16:27 # M/D Reply Permalink

    JSP 로 파일업로드 구현하신분
    소스 좀 공유해주세요 ^^
    mobil52@naver.com

  10. 비밀방문자 2010/10/01 02:11 # M/D Reply Permalink

    관리자만 볼 수 있는 댓글입니다.

  11. 코드는 2011/04/20 22:31 # M/D Reply Permalink

    업로드를 담당하는 클라이언트

  12. 초보개발자 2011/05/16 17:19 # M/D Reply Permalink

    한번 구동 해 보았는데요..
    Log.e("Test", "File is written");
    mFileInputStream.close();
    dos.flush(); // finish upload...

    dos.flush(); // finish upload...이부분에서 에러가 나면서
    바로 Catch 로 빠져 버리네요..;;
    어떤애러가 나는건가요..?
    (서버는 제컴내부 서버를 이용 했습니다..)

  13. message 2011/05/24 21:34 # M/D Reply Permalink

    개념 잡는 용도로 보시면 됩니다.

  14. 박은지 2011/06/03 13:11 # M/D Reply Permalink

    파일을 write하는부분에서
    permission denied 익셉션이 발생하고나서

    몇번더 가비지 컬렉션을 하더니
    request time failed.: java.net.SocketException: Address family not supported by protocol 이라고 뜨네요 ㅠㅠ
    왜그런가요 ?ㅠㅠ

    도와주세요

  15. ray ban outlet 2011/10/20 12:29 # M/D Reply Permalink

    new style <a href="http://www.echeapraybansunglasses.com/"><strong>ray ban 2140</strong></a> sunglasses and <a href="http://www.echeapraybansunglasses.com/"><strong>ray bans outlet</strong></a> on there, people like cool <a href="http://www.echeapraybansunglasses.com/"><strong>ray ban 3025</strong></a>, no sunlight that buy <a href="http://www.echeapraybansunglasses.com/"><strong>aviator sunglasses for men</strong></a> nice.

  16. constitution-day 2011/12/08 18:55 # M/D Reply Permalink

    블로그를 위한 감사 합니다 하나님! 인터넷 같은 장소에 대 한는 것이 지 않은

  17. freeadultdating 2011/12/10 03:43 # M/D Reply Permalink

    정말로 아름답네여

  18. credit cards for no credit 2011/12/12 20:20 # M/D Reply Permalink

    전용된 리더를 여기 있는 모든 시간이 귀하의 콘텐츠를 업데이트 계속 노력 하겠습니다.

  19. bad credit credit cards 2011/12/13 15:03 # M/D Reply Permalink

    환상은 매우 유익한 올려. 이 분야의 다른 전문가들이 이것을 통지하지 왜 폰더. 당신은 서면으로 진행해야합니다. 난 확신 해요

  20. chat 2011/12/17 13:11 # M/D Reply Permalink

    안녕하세요 모두 들! 이 메시지에 더 쓸 수 없습니다! 이 게시물을 읽고 생각나 전에 내 룸메이트가! 그는 항상 그것에 대해 얘기 보관. 그에 게이 문서를 보내드립니다. 비교적 확실히 그가 독서를 즐길 것 이다. 공유 해 주셔서 감사 합니다!

  21. wgtgolf 2011/12/21 15:14 # M/D Reply Permalink

    좋은 포스트와 좋은 블로그! 제가 구글 그리고 물론 즐겨찾기 서핑이 발견. 내 영어 죄송 합니다!

  22. hottestwomenintheworld 2012/01/05 04:28 # M/D Reply Permalink

    바라건대이 이벤트가 깡통에게 참가자 그거 좋은 교훈을 제공합니다. 그래서 그들은 리소스 사람이 일정을 따라 헛되이되지 않았습니다.

  23. Search Alyze 2012/01/05 16:00 # M/D Reply Permalink

    너무 많은 정보를 위한 감사 합니다

  24. freechatting 2012/01/07 06:10 # M/D Reply Permalink

    그 동안 전 때 여기를 방문 하지만 세대는 여전히 살아 있고

Leave a comment
[로그인][오픈아이디란?]
« Previous : 1 : ... 20 : 21 : 22 : 23 : 24 : 25 : 26 : 27 : 28 : ... 47 : Next »

블로그 이미지

- Tcher

Notices

Site Stats

Total hits:
84622
Today:
58
Yesterday:
91