I'm trying to upload a pdf file to my local storage, using javascript, but no tutorial I used seems to work.
I have my 'add function' in my service:
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));
};
And I don't know how to also add a pdf file. This is how the html looks for the above code:
<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>
The input and button are components* Next on the controllers add functionality:
addElement() {
this.Service.add(this.title, this.description);
}
How do I go about adding the pdf file and saving it to the local storage, so that I can even download it later?