【发布时间】:2018-10-05 23:29:42
【问题描述】:
我正在自己构建一个 Cordova 应用程序,我需要创建一个新文件夹来将图像存储在手机的内部存储器中。我在网上浏览了很多文章,每个人都给出了相同的解决方案,但它对我不起作用。
以下是我在 OnDeviceReady 事件中使用的代码,但它不起作用。
var new_directory = 'TEST';
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory(new_directory, { create: true }, function (file) {
alert("got the file: "+ file.name + ', ' + file.fullPath);
});
}, function(error) {
alert("can't even get the file system: " + error.code);
});
为了调试,我也尝试过提醒
cordova.file
object 但它显示为未定义。 我试过写简单的文件请求语句,即使它不工作
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, alert('success'), alert('failed'));
当我编写上面的代码时,其余的 javascript 代码也不起作用。
请帮我解决这个问题。
【问题讨论】:
-
您想将图像文件保存在哪里?在应用程序文件夹或照片库中?
-
我想将文件保存到内部存储根目录的文件夹中。这个问题是否可能是因为我有 android Nougot 并且它与 cordova-plugin-file 不兼容
标签: javascript cordova ionic-framework cordova-plugins phonegap