我如何阅读本地文本文件与JavaScript? [英] How do I read in a local text file with javascript?

查看:142
本文介绍了我如何阅读本地文本文件与JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用本地文件来选择一个文件,并逐行阅读文本来解释它。我的程序是为了读取一个文本文件,并从中读取问题来做一个测试程序。该文件不应该上传,只能在本地读取。如果解决方案只适用于Chrome和Firefox,这是好的。

我试过了很多东西,但是到目前为止我看到的东西是不可能出于安全原因,或者它不起作用正常。我

这是我目前的代码:
http:/ /pastebin.com/uKvEfvZZ

解决方案

使用 HTML5文件API 。它允许您在本地选择和读取文件。


I am trying to use to select a file locally and read the text in it line by line to interpret it. My program is meant to read a text file and read questions from it to make a test taking program. The file should not be uploaded, and only read locally. It is okay if the solution only works on chrome and firefox.

I have tried looking through many things, but so far what I seem to see is that it is not possible for security reasons, or it is but it doesn't work properly. I

This is my current code: http://pastebin.com/uKvEfvZZ

解决方案

Use HTML5 file API. It allows you to select and read files locally.

这篇关于我如何阅读本地文本文件与JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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