locked
How to upload an image by using winJS.xhr and how to write a servlet to recieve the image in service

    Question

  • I use phonegap to build a windows8 store app(using html5 and javascript). I can get the image's src in phone.

    But I don't know how to write the javascript to upload .

    And how to write a service(I'm not familiar with WCF,I want to use servlet in java) to recieve it?

    Saturday, August 31, 2013 3:57 AM

Answers

  • Hi IcedreamSJTU,

    Oh, because you mentioned "I can get the image's src in phone", therefore I think you are working for a phone app, sorry for that.

    Normally when you take the photo by camera, your photo exist in the memory as the stream, you could directly use this stream instead of using the getFileAsync code below:

    picturesLibrary.getFileAsync("myBitmap.bmp").then(
        function completeFile(file) {
            return file.openAsync(Windows.Storage.FileAccessMode.readWrite);
        })

    For the last question, I do not have such experience, you could ask question in WCF forum to get more help with how to setup a webservice to receive image.

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by IcedreamSJTU Tuesday, September 3, 2013 3:44 AM
    Monday, September 2, 2013 6:49 AM
    Moderator

All replies

  • Hi IcedreamSJTU,

    The first thing I want to provide you is a short tutorial: How to upload binary data with WinJS.xhr (Windows Store apps using JavaScript and HTML), the sample code is for upload the image.

    And in your word, you are developing for a phone. Windows Store app has a bit difference with Phone Store App, so if you ask question at Phone Dev Forum, I think you will get more experts involved.

    Last but not least, you should really ask question on Java dev forum for a servlet question.

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 2, 2013 1:30 AM
    Moderator
  • Firstly thanks for your answer.  But I am not developing for a phone but a surface. Phonegap can be used in windows8(not windows phone 8). 

    I have read the tutorial but I still have some problem: The way to upload  needs to know the image's name, but I want to upload the photo that I take use camera.Idon't know the img's name.

    And also I don't know how to recieve the image in service.

    Monday, September 2, 2013 3:14 AM
  • Hi IcedreamSJTU,

    Oh, because you mentioned "I can get the image's src in phone", therefore I think you are working for a phone app, sorry for that.

    Normally when you take the photo by camera, your photo exist in the memory as the stream, you could directly use this stream instead of using the getFileAsync code below:

    picturesLibrary.getFileAsync("myBitmap.bmp").then(
        function completeFile(file) {
            return file.openAsync(Windows.Storage.FileAccessMode.readWrite);
        })

    For the last question, I do not have such experience, you could ask question in WCF forum to get more help with how to setup a webservice to receive image.

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by IcedreamSJTU Tuesday, September 3, 2013 3:44 AM
    Monday, September 2, 2013 6:49 AM
    Moderator