【发布时间】:2017-12-04 03:58:18
【问题描述】:
我正在尝试使用 javascript 将 pdf 文件上传到我的本地存储,但我使用的教程似乎没有用。
我的服务中有我的“添加功能”:
add(title, description) {
let old = JSON.parse(localStorage.getItem('list')) || [];
let new = {
'title': title,
'description': description,
};
old.push(newBook);
this.object = old;
localStorage.setItem('list', JSON.stringify(old));
};
而且我不知道如何添加 pdf 文件。 这是 html 查找上述代码的方式:
<input class="title"
label="Title"
type="text"
input-id="title"
bind="$ctrl.title"
placeholder="AddTitle">
</input>
<input class="description"
label="Description"
type="text"
input-id="description"
bind="$ctrl.description"
placeholder="Add Description">
</input>
<button theme="" on-click="$ctrl.addElement()">Add</button>
输入和按钮是组件* 接下来在控制器上添加功能:
addElement() {
this.Service.add(this.title, this.description);
}
如何添加 pdf 文件并将其保存到本地存储,以便以后下载?
【问题讨论】:
-
该解决方法使用 jquery 并通过复制图像数据来保存文件对象。我不能使用jquery。另一个解决方案保存的是通用对象,而不是文件对象。 @SureshKamrushi
标签: javascript angular local-storage