locked
HOW TO SEND IMAGE TO DATABASE(BASE64)

    Question

  • I want to send an image to my database. im using base64 . im using wcf restful.


    1002614D

    Friday, July 6, 2012 3:16 AM

Answers

All replies

  • You could use the WinRT classes for that:

    For Strings

    CryptographicBuffer = Windows.Security.Cryptography.CryptographicBuffer;
    BinaryStringEncoding = Windows.Security.Cryptography.BinaryStringEncoding;

    String.prototype.base64 = function() {
        return CryptographicBuffer.encodeToBase64String(CryptographicBuffer.convertStringToBinary(this, BinaryStringEncoding.utf8));
      };

    or if your Image is already an IBuffer just use CryptographicBuffer.encodeToBase64String(imageBuffer)

    Friday, July 6, 2012 8:35 AM
  • maybe I should  show my code for a better understanding

    my javascript code:

    function

     c

    senddata() {hange to base64 string

     var imagedata = fileToBase64('testCanvas');

     

    var imagedata = document.getElementById.fileToBase64('testCanvas').;

    ButtonToAdd.addEventListener(

    'click', function () {

    var baseURL = "http://localhost/CCWService/data.svc/subcrime/";

    var baseURL1 = "http://localhost/CCWService/data.svc/subcrimeimg/";

    //var url = baseURL + crimeID + "/" + desc + "/" + lat + "/" + long + "/" + useIP + "/" + phone;

    var url = baseURL + desc + "/" + lat + "/" + long + "/" + useIP + "/" + phone;

    var url1 ="";

    WinJS.xhr({ url: url }).then(

    function (r) {

    var result = JSON.parse(r.responseText);

    crimeID = result.subcrimeResult;

    url1=baseURL1 + crimeID +

    "/" + imagedata;

    }

    ).then(WinJS.xhr({ url: url1 }).then(

    function (r) {

    var result = JSON.parse(r.responseText);

    msg.innerHTML = result.subcrimeResult;

    var msg = new Windows.UI.Popups.MessageDialog("Thank You for helping the community! The information have been succesfully send!", "Successful!"); msg.showAsync();

    }));

    });


    1002614D

    Friday, July 6, 2012 9:14 AM
  • Hi M,

    In Metro style apps, access to localhost is blocked.  You cannot submit an app to the store that is using localhost.

    In a testing scenario only you can temporarily work around the issue by following this article:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx

    -Jeff


    Jeff Sanders (MSFT)

    Monday, July 9, 2012 12:55 PM
    Moderator