I get a file inputted in file input using file reader and store it in another object which I store in localStorage using JSON.stringify it returns an empty object {}. Then, when I use JSON.parse I get an empty object ('{}')
//getting the file
const contacts = []
const fileInput = document.querySelector("input[type=\"file\"]")
fileInput.addEventListener("change", () => {
const pic = fileInput.files[0]
contacts.push({pic}) //plus other details
localStorage.setItem("contacts", JSON.stringify(contacts))
console.log(fileInput.files[0])//returns a file object
console.log(JSON.stringify(fileInput.files[0]))//returns an empty
})
<input type="file">
Is there any way to store it in the localStorage in a way that when it is parsed a file object is returned?