The error you are seeing is a SECURITY_ERROR
. See: https://developer.mozilla.org/en-US/docs/Web/API/FileError?redirectlocale=en-US&redirectslug=DOM%2FFileError for more details. This is because you are using the file:
protocol. You have 2 ways around this:
- Serve files from a (local) webserver.
- Use Chrome and launch with the
--allow-file-access-from-files
flag.
In general, the file system is meant to access sandboxed local files, so you can't access just any file on disk (this would be a massive security hole). So, you can't just read/write to C:\My Documents\my_credit_card_numbers.txt
.
A really great tutorial is available at HTML5 Rocks