I am wondering how to upload an image file to web server ?
If I have developed a web sevice which will read byte, in the cell phone, I use J2ME. Say, the cell phone has a camera . After capturing photo, how could the J2ME find that photo file and upload it ?
Yes, here we have an assumption, we don't use the cell phone vendor's built-in appliction to upload carema photo.
In general you can't do this. There is no MIDP API that allows you to access the file system such that you could extract photos stored by the native camera application.
Some MIDP 2.0 devices have APIs which allow your MIDlet to control the camera and save the pictures that are taken while running your MIDlet, but you still can't access photos stored by the native camera application.
There may be some OEM specific extensions that allow this on some phones, but there's no runs-on-anything solution.
You could use the FileConnection API, if available for your target platform. Many phone from SonyEricsson has this support. I have not looked at any other phones, but I am pretty sure that many other phones also has has the same support. BTW.
I am able to upload those image which are less than 2 kb but for bigger image its not possible. So if u find out the solution please share with me
Joined: Jan 07, 2005
Which Http request method do you use? HttpConnection.POST?
Joined: Mar 24, 2005
Yes, i am using http post request method. But if image size larger than 2048 bytes then http/1.1 response header server : Apache/1.3.31 (Unix) mod_fastcgi/2.4.2 connection : close transfer-encoding : chunked content-type : text/html; charset=iso-8859-1
"Once the camera video is shown on the device, capturing an image is easy. All you need to do is call VideoControl's getSnapshot() method.You'll need to pass an image type, or null for the default type, PNG. You can find out ahead of time the image types that are supported. The video.snapshot.encodings system property contains a whitespace-delimited list. The Nokia 3650 supports PNG, JPEG and BMP.
The getSnapshot() method returns an array of bytes, which is the image data in the format you requested. What you do at this point is up to you: you might save the bytes in a record store, send them to a server, or create an Image from them ... "
We don't normally recommend resurrecting long-dead threads, but this is something that's likely to be useful to a lot of people.
I actually had to write a camera upload app last year and I did it in .Net and prototyped a J2ME version as well. In the .Net version, the camera wrote a JPEG file and the camera API returned its location. I opened the file and I then transmitted its contents using an HTTP MIME POST, along with some application-specific side data.
I don't remember clearly the J2ME equivalent, but I think that the multimedia package returned some sort of stream handle which could be uploaded using the same basic mechanism. We've have a few others on this forum do similar things over the last few months, I think, so if anyone needs to know details, just ask.
An IDE is no substitute for an Intelligent Developer.
Hi, I m also having a problem regarding picture upload.. i m exactly doing the same thing ,i.e getting image in jpeg encoding using getsnapshot() and then passing byte over stream using HTTP POST, Now my problem is regarding server side. There I m using PHP. but i m unable to get image ,i mean exactly how can i fetch thoese raw bites and turn it in image and move it in a directory. Can anyone help ??
I am new to j2me.I want to upload image to server. While I am uploading image from emulator it is hitting the server. But while I am uploading image from mobile it is showing exception.
org.apache.commons.fileupload.FileUploadBase$UnknownSizeException: the request was rejected because its size is unknown
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest (ServletFileUpload.java:116)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process (Http11Protocol.java:634)
at java.lang.Thread.run(Unknown Source)
Here I am sending Mobile and application Number and capture image in bytes `(imagecapturephoto1)`. Capture is storing in view after taking photo.But when we are uploading it is showing exception.