从本地计算机读取文件 [英] Read a file from local machine

查看:125
本文介绍了从本地计算机读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于C盘的文件。

我想以单数形式5读取该文件的内容。



我尝试了什么:



我正在尝试在打字稿中使用filereader。

但是如何将文件作为一个文件发送typescript的参数?

解决方案

网站无法从用户的磁盘中读取随机文件。您只能通过在< input type =file> 中选择文件,或者将它们拖入,才能读取用户明确授予您访问权限的文件。你的申请。



如果用户没有选择该文件,那么你的代码就无法读取它。



使用来自Web应用程序的文件 - Web API | MDN [ ^

I have a file located at C drive.
I want to read contents of that file in anular 5.

What I have tried:

I am trying to use filereader in typescript .
However how to send file as a parameter from typescript ?

解决方案

Websites cannot read random files from the user's disk. You can only read files which the user has explicitly given you access to, either by selecting them in an <input type="file">, or by dragging them into your application.

If the user hasn't selected the file, then your code cannot read it.

Using files from web applications - Web APIs | MDN[^]


这篇关于从本地计算机读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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