你可以使用PhoneGap。的JS方法读取www文件夹中的文件吗? [英] Can you read files in the www folder using PhoneGap.'s JS methods?

查看:153
本文介绍了你可以使用PhoneGap。的JS方法读取www文件夹中的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JavaScript(非原生代码),可以从 www 文件夹读取文件夹和文件,例如 phonegap.js 是?

Using JavaScript (not native code), is it possible to read folders and files from the www folder where, for example, phonegap.js is?

我设法通过AJAX调用读取文件内容,但我想知道是否有不同的方法。

I've managed to read file contents with AJAX calls, but I'd like to know if there is a different way. Besides, you can't read folders like that.

根据我所见,档案 FileEntry PG只公开磁盘上持久或临时位置的工作的API。我似乎不能指定任何我想要的位置。

From what I've seen, the File and FileEntry APIs that PG exposes only work on Persistent or Temporary locations on disk. I can't seem to be able to specify any location I want.

那么,有没有办法做到这一点与JS?

So, is there a way to do that with JS?

推荐答案

无法使用FileReader做它,因为它只能从文件系统读取。对于应用程序中的文件,它们实际上不在文件系统上,您将需要使用XHR来读取它们。

No you can't do it with the FileReader as it can only read from the file system. For files in your app they are not actually on the file system and you will need to use XHR to read them.

但是,我最近写了一个XhrFileReader接口,允许您使用典型的FileReader方法,但仍然读取与您的应用程序打包的文件。

However, I recently wrote a XhrFileReader interface to allow you to use the typical FileReader methods but still read files packaged with your app.

http://simonmacdonald.blogspot.ca/2013 /02/phonegap-android-xhrfilereader.html

这篇关于你可以使用PhoneGap。的JS方法读取www文件夹中的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆