Save temporary files in sessionStorage

Asked

Viewed 23 times

0

Hello, I wonder if it is possible to store files in sessionStorage and how I can do it. I tried with JSON.stringfy() and JSON.parse() methods and no success as follows

var elemento = document.getElementById('inputComArquivo');

sessionStorage.setItem('arquivos', JSON.stringfy(elemento.files));

  • I think the API of storage has a memory limit, and storing large files is not a good idea. Files will be large?

  • Searching around, apparently the limit is 5MB. And has this site to test in practice :) . And I can’t imagine a case that makes sense, you really need to save the contents of a file there? Maybe your problem is different and you’re trying to solve it in a bad way

  • Hello, thanks for the return, thanks! Well, in this case is a registration page with a field where I can attach up to 3 files (.pdf, xlsx, etc...). If I for example click on "register" and there is some error in the registration as an empty field, the page simply reloads me alerting me which fields I have not filled in and this is how I lose the files I previously attached and have to attach again in the register (typical of Django) My terefa is precisely to keep the files I entered if the page reloads due to error in the registration. That’s all it’s for.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.