如何在Phonegap中的WebSql(Sqlite)中存储和检索Image

时间:2017-03-17 07:08:13

标签: javascript android sqlite cordova

我已经在WebSql(Sqlite)数据库中创建了捕获图像和存储的演示,但是我的图像没有存储在我的WebSql(Sqlite)中Db以下是我的代码

我想在WebSql(Sqlite)中保存我的捕获图像,然后将图像从WebSql(Sqlite)上传到Sql Server数据库..

谢谢..

这是我的Js档案



function capturePhoto() {
    // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
        quality: 25,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.CAMERA,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 500,
        targetHeight: 500,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: true
    });
}
 
function onPhotoURISuccess(imageURI) {
    var latitute = window.localStorage.getItem("loginLatitude");
    var longitude = window.localStorage.getItem("loginLongitude");
    var placeImage = document.getElementById('smallImage');
    placeImage.src = imageURI;
    placeImage.style.display = 'block';
    console.log(imageURI);
    db = window.openDatabase("Database", "1.0", "FootPlatee", 20000); 

    db.transaction(function (tx) {
        tx.executeSql('CREATE TABLE IF NOT ImageINSQlite(id INTEGER PRIMARY KEY AUTOINCREMENT,ImageUrl BLOB, Latitute double, Longitute double)');
        tx.executeSql('INSERT INTO ImageINSQlite(ImageUrl, Latitute, Longitute ) VALUES ("' + imageURI + '", "'+latitute+'", "'+longitude+'")',function(tx, res) {
            alert(res);
        });
    });

    function onFail(message) {
        alert('Failed because: ' + message);
    } 

} 




0 个答案:

没有答案
相关问题