Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2004

    MIDlet upload photo problem

    Hi all, I am developing a MIDlet which allows the user to take a photo add some text and then upload it to a servlet.
    My problem is with uploading.
    I upload
    an Integer
    A string
    size of photo byte[]array

    I can upload the first 3 no problem but not all the bytes for the photo seem to be received by the servlet..

    My code for the MIDlet is

    String job_No = Integer.toString(upJobNo);
    String picString = new String(upLoadImage);
    int picSize = upPicture.length;
    String size = Integer.toString(picSize);

    String allData = job_No+"&"+upPicNotes+"&"+size+"&"+picString;
    byte[] dataToSend = allData.getBytes();

    String dataLength = Integer.toString(allData.length());

    c = (HttpConnection)Connector.open(url2, Connector.READ_WRITE, true);
    c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
    "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("content-type", "multipart/form-data; " );
    c.setRequestProperty("Content-Length", dataLength);
    c.setRequestProperty("Content-Language", "en-CA");

    os = c.openOutputStream();



    and my servlet code is....

    int dataLength = request.getContentLength();

    BufferedReader br = request.getReader();

    String allData = "";

    String data= "";
    while((data = br.readLine()) != null)
    allData = allData + data;

    I then seperate the String into the individual parts again, and there is never the full bytes for the photo..
    What am I doing worng??

    also the request.getContentLength() returns -1.

    Any help will be appreciated.
    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Sep 2005

    Re: MIDlet upload photo problem

    Hi Kmcgivern,
    I am with a similar problem. could you send me its complete code for me to analyze, MIDLet and Servlet?
    Thanks. Clésio de Miranda.
    e-mail: clesiodemiranda@yahoo.com.br

  3. #3
    Registered User
    Join Date
    Sep 2008

    Re: MIDlet upload photo problem

    Hi Kmcgivern,
    I think i can help. I know the way to upload multipart (image...) data to mysql database using php, and how to download that from mysql. after downloding u can append the image to an web site. If u can send me ur codings, i think i can make it work and send u the completed work.

    here's my email : rronyyy@yahoo.com

  4. #4
    Regular Contributor
    Join Date
    Jul 2003

    Re: MIDlet upload photo problem

    have a look at this example on Forum Nokia Wiki,


    As for storing it in the Database you can either store the image itself as a blob or simply store the path to the image as text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts