PhoneGap-如何制作图像的副本并保存在应用程序文件夹中



在我的应用程序中,用户可以从画廊中选择一个图像,此图像将在用户帐户中使用,并且无法通过画廊访问,因此我需要SABE此图像的副本cordova.file.dataDirectory,但我不知道如何获取本地文件uri进行复制和保存。

如何将图像文件从本地设备复制到cordova.file.dataDirectory

我的应用程序有一个屏幕,用户可以在其中使用输入文件提供标题并选择图像。

我正在使用Cordova插件文件

搜索我在旧文档的旧文档中找到了解决方案(最近的文档没有此信息)。复制文件只需使用copyto方法。

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(entry){
        var parent = document.getElementById('parent').value;
        parentEntry = new DirectoryEntry({fullPath: parent});
        // copy the file to a new directory and rename it
        entry.copyTo(parentEntry, "file.copy", function(entry){
            console.log("New Path: " + entry.fullPath);
        }, function(error){
            console.log(error.code);
        });
    }, null);

最新更新