5

我想导入和导出 CSV。我已经弄清楚如何让 iPad 将我的应用程序识别为打开 CSV 文件的应用程序。

从那里虽然我迷路了。我找到了有关 iPad 如何通过 application:didFinishLaunchingWithOptions 或 handleOpenURL 发送文件的解释...

我发现在我的 js 文件中添加一个名为 handleOpenURL(url) 的函数会将文件的 url 传递给我......所以现在我有了这个。

这很好,因为我现在知道有人以这种方式打开了我的应用程序。 酷...但是我如何获取该 URL 的内容?

4

1 回答 1

3

知道了!呜呜呜,这就是我做的...

function handleOpenURL(url)
{
    window.resolveLocalFileSystemURI(url, onResolveSuccess, fail)
}

function onResolveSuccess(fileEntry)
{
    fileEntry.file(win, fail);
}

function win(file) {

    var reader = new FileReader();
    reader.onloadend = function(evt) {
        alert("succes");
        alert(evt.target.result);
    }
    reader.readAsText(file);
}

function fail() {        
    alert('fail');
}
于 2012-01-21T23:58:31.997 回答