简体   繁体   English

JavaScript 可以读取硬盘驱动器上的文件吗?

[英]Can JavaScript read files on the hard drive?

Here I have learned that it is possible with JavaScript in HTML to create files offline and save them on the hard disk. 在这里我了解到可以使用 HTML 中的 JavaScript 离线创建文件并将它们保存在硬盘上。

But what about reading files?但是读取文件呢? Can JavaScript access, say one of my .txt files on my self phone and display the read data (or at least place it in the local storage)? JavaScript 可以访问,比如我自己手机上的一个 .txt 文件并显示读取的数据(或至少将它放在本地存储中)?

I know that it is possible with PHP, but there is no PHP on my cellphone, while HTML is always there.我知道用 PHP 是可能的,但是我的手机上没有 PHP,而 HTML 总是在那里。

You can use <input type="file"> and FileReader to read files stored at local filesystem, see File API ;您可以使用<input type="file">FileReader读取存储在本地文件系统中的文件,请参阅File API also How FileReader.readAsText in HTML5 File API works? HTML5 File API 中的 FileReader.readAsText 是如何工作的? . .

If trying at Chromium or Chrome to read file: protocol launch the browser with --allow-file-access-from-files flag, without other Chrome instances running, or use a different --user-data-dir , see Read local XML with JS .如果尝试在 Chromium 或 Chrome 中读取file:协议使用--allow-file-access-from-files标志启动浏览器,而不运行其他 Chrome 实例,或使用不同的--user-data-dir ,请参阅读取本地 XML与 JS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用javascript从硬盘读取文件 - Reading files from hard drive with javascript 如何从网页读取和运行硬盘上的文件? - How to read and run files on hard drive from a webpage? 使用JavaScript格式化硬盘 - Format hard drive with javascript Firefox运行缓慢,JavaScript在硬盘驱动器上运行,而不是上传文件 - Firefox slow with javascript running off the hard-drive, not with uploaded files 自动建议硬盘上的文件(反应/电子) - Autosuggest with files on hard drive (React / Electron) JavaScript 待机功能是否存储在 RAM 或硬盘驱动器中? - Is JavaScript standby functionality stored in RAM or the hard drive? 如何在javascript中从D盘读取本地文件 - How can i read local file from D drive in javascript 谷歌驱动器使用JavaScript下载文档:无法下载文件 - google drive download document using javascript :can't download files 我的外置硬盘中了病毒,我发现了这个非常可疑的 javascript 文件。 有人可以帮我分析这个文件吗? - My external hard drive got virused and I found this very suspicious javascript file. Can someone analyze this file for me? 使用javascript从网站将图像客户端下载到硬盘 - Downloading an image client side to the hard drive from a website using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM