loadFromDisk
fun Document.loadFromDisk(accept: String = "", onError: LoadContext.() -> Unit = {}, onLoad: LoadContext.(ByteArray) -> Unit)(source)
Load some binary content from disk, presenting the user with a dialog to choose the file to load.
This method extends the global document
variable, so you can use it like this:
document.loadFromDisk(".png") { bytes -> /* ... */}
Content copied to clipboard
Parameters
accept
A comma-separated list of extensions to filter by (e.g. ".txt,.sav").
onError
A callback which will be invoked if the file could not be loaded.
onLoad
A callback which will contain the contents of your file, if successfully loaded. The callback is scoped by a LoadContext which contains additional information about the file, such as its name and mime type.
See also
FileReader.readAsArrayBuffer