简体   繁体   English

如何通过使用HTML / JS / Jquery提供本地文件路径来访问本地文件?

[英]How can I access a local file by giving the local file path using HTML/JS/Jquery?

Let's say I've csv file in my C:/test/tes.csv and I've a text box in html file and paste the above path in text box. 假设我在C:/test/tes.csv中有一个csv文件,在html文件中有一个文本框,并将上面的路径粘贴到文本框中。 I've "Load Data" button near by the textbox. 我在文本框附近有“加载数据”按钮。 when I click on the button I want to alert the content of the file. 当我单击按钮时,我想提醒文件内容。 Insted of default file picker in HTML/JS, there is anyway to load the data? 安装了HTML / JS中的默认文件选择器后,是否仍要加载数据? I want to use it in my application. 我想在我的应用程序中使用它。

Please help me to figure out it 请帮我弄清楚

You should try and use the FileReader API , which allows you to read the contents of files (or raw data buffers) stored on the user's computer. 您应该尝试使用FileReader API ,它使您可以读取存储在用户计算机上的文件(或原始数据缓冲区)的内容。

Eric Bidelman wrote this awesome article that can help you get started. 埃里克·比德尔曼(Eric Bidelman)撰写了这篇很棒的文章 ,可以帮助您入门。

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

相关问题 我如何在 HTML JS 中打开带有变量链接的本地文件 - how can i open local file with a variable link in HTML JS 使用本地计算机上的js / html文件读取本地文本文件 - Read local text file using js/html file on on local machine 使用js文件访问本地JSON对象 - Access a local JSON object using a js file 如何从HTML读取本地访问数据库文件? - How do I read a local access database file from HTML? 如何在 Javascript 中读取具有固定路径的本地文件? 我只有文件的位置作为字符串。 不允许使用 HTML 表单 - How can I read a local file with a fixed path in Javascript? I only have the location of the file as a string. NO HTML forms allowed 当用户使用HTML5 File API按下按钮时,如何读取本地文件? - How can I read a local file when the user presses a button using the HTML5 File API ? 如何在我的 js 代码中使用此 local.txt 文件? - How can I use this local .txt file in my js code? 如何在 React js 中解析本地 JSON 文件? - How can I parse through local JSON file in React js? 如何仅使用路径使用HTML5文件API读取本地文件 - How to read a local file using HTML5 file API using path only 如何使用 javascript(文件是本地文件)从一个 HTML 文件重定向到另一个文件? - How can I redirect from one HTML file to another using javascript (the files are local)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM