javascript - 在angularjs中读取表单输入的文件内容
问题描述
我的硬盘中有一个 JSON 文件,当我使用输入字段选择它时,如何读取该文件的内容?
我必须在某些 API 中读取内容并将内容作为数据发送!
我需要这样的东西:
<input type="file" id="dashboardExportedFile">
<button type="button" ng-click="importDashboard">Import</button>
<script>
$scope.importDashboard = function (
var content = $("#dashboardExportedFile").content
console.log(content);
};
</script>
解决方案
我认为你需要一个文件阅读器。按照我的链接查看带有 .txt 文件的工作示例。希望你可以使用它:[JSFiddle][1]
[1]: http://jsfiddle.net/alexsuch/6aG4x/
推荐阅读
- javascript - Javascript - Cheerio - 网页抓取
- lua - LUA ERROR 尝试对布尔值执行算术运算
- rust - 使用异步函数解决“无法返回值引用函数参数”的最佳方法是什么?
- python - Django - OneToOneField 不断返回 None
- c++ - 为什么我不能在 `while` 循环中验证 `pow` 函数?
- r - 使用 ggplot 将两个矩阵合二为一
- php - 无法访问本地主机中的数据库,即使它确实存在
- r-markdown - 我可以在 RMarkdown 中引用使用 table1 制作的表格吗?
- python - 寻找关键词
- perl - -s 是否总是在 Perl 中的目录上返回零?