简体   繁体   中英

Phonegap camera.getPicture imageURI only temp in Cache folder, how can I get permanent imageSRC

Hi im working on a Phonegap App.

Im using the camera plugin to get a picture and display it and save the imageURI in localstorage. All this works but after a time the images are removed from the cache folder so I need a permanent imageURI/imageSRC. Does anyone know how I can do that ? Can I get the imageSRC from the Gallery somehow ? This is my code:

        $('.photo').click( function()
{
    navigator.camera.getPicture(onSuccess, onFail, { 
    quality: 50,
    destinationType: Camera.DestinationType.FILE_URI,
    saveToPhotoAlbum: true});

    function onSuccess(imageURI) {
        $.mobile.changePage("#four", { transition: "slide", reverse: true, changeHash: false});
        $('img').remove();
        var img = $('<img />');
        img.attr('src', imageURI);
        img.attr('width', "200");
        img.attr('height', "200");
        img.appendTo('#photos');
    }
    function onFail(message) {
        //alert('Failed because: ' + message);
    }
});

Later in my code i get the img src like that:

   var bild = $('img').attr('src');

then I save it in an array in local storage and display it on another page.

You should not by any means use the app's localStorage to save images nor files, as this provides a very limited amount of space, and that space varies depending on device, platform, manufacturer, etc. On some Android versions, this space is limited to 2MB, or 10MB if using the standalone webview. Use the file plugin instead if you want to save them on the device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM