简体   繁体   中英

Accessing files selected by user through HTML5 File System API across several refreshes

Okay, so the user has selected multiple files through the file chooser dialog and using HTML5 File System API I display their names and sizes. After that's done, I refresh the same page, which is served by a servlet; and on refresh the servlet writes in some JavaScript that again uses the 'file' vars to access the last modified date. This doesn't seem to work.

I believe this is a session management issue maybe the HTML5 File API does not allow access across different session. Or is it only supposed to be used for javascript to be executed in a single go?? Please tell me how I can access the same file vars across several pages, if needed they can be set to the same session.

You will need to use HTML5's window.sessionStorage , which will be cleared at the end of the browser session.

Or, if you want a persistent storage then you need window.localStorage .

All this is assuming that all of your pages are being served from the same domain, otherwise you will a problem with the Same-origin policy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM