如何使用javascript检查移动sd卡中是否存在文件

how to check file is exist or not in mobile sd card using javascript

本文关键字:是否 存在 文件 sd 何使用 javascript 检查 移动      更新时间:2023-09-26

如何使用PhoneGap检查Android SD卡上是否存在Excel文件(.xlsx)?如果文件退出,如何通过javascript导入和导出文件内容?

首先将cordova文件插件添加到您的项目中。然后使用以下代码:

    var reader = new FileReader();
    var fileSource = <file path>;
    reader.onloadend = function(evt) {
        if(evt.target.result != null) {
            // If you receive not null value the file exists
        } else {
            // Otherwise the file doesn't exists
        }         
    };
    // We are going to check if the file exists
    reader.readAsDataURL(fileSource);