1

Hi I am trying to upload a file from my android device to a web server using php. I've achieved it using MultiPartEntry and accessing the file in php using $_FILES. However, since using this approach the uploaded file has a very large resolution.

At present I capture the photo, resize it and convert it to a byte array. I could re-save the bitmap to a file and then upload the file using the above approach. However, since I already have bitmap as a byte array and its possible to add it to the MultipartEntry I thought this would be a better solution.

http://vikaskanani.wordpress.com/2011/01/29/android-image-upload-activity/

Android:

MultipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte [] ba = bao.toByteArray();
entity.addPart("image", new ByteArrayBody(ba, "photo.jpg"));

My question is how do I access the image date in the http post?

Many thanks

Bear
  • 1,541
  • 3
  • 20
  • 32
  • You may have to read the raw POST data via the php://input stream and process out the file data yourself. – Marc B Apr 15 '11 at 19:01
  • Do you have an example? It appears that you cannot do this when using multi part data http://stackoverflow.com/questions/1864280/reading-raw-data-from-a-flash-post-request-images and http://www.codediesel.com/php/reading-raw-post-data-in-php/ – Bear Apr 15 '11 at 20:23

1 Answers1

0

take a look at this post it's a good guide http://www.mattorama.net/blog/2011/2/19/file-uploads-with-cxf-multipart-form-posts.html

J.H.
  • 1
  • 1