This module exposes attributes that you can use to read files into Elm.
The format you want your data in.
DataURL - a data URL as specified by RFC 2397.
Base64 - Base64 encoded as specified by RFC 4648
Text encoding - Text, encoded using the specified encoding (See https://www.w3.org/TR/encoding/#concept-encoding-get)
An error returned from file reading. This corresponds to a
DomException (name and message) or a FileError (code)
gotten when trying to read the file.
Add these attributes to an input node to get the contents of the selected file.
type Msg
= FileSelected File
view =
Html.input (fileInput DataURL FileSelected) []Add these attributes to an input node to get the contents of the selected files.
type Msg
= FilesSelected (List File)
view =
Html.input (filesInput DataURL FilesSelected) []Add these attributes to any node to create a "drop zone" for files
and get the contents of the dropped files. The enterMsg and leaveMsg
messages could be used to visually indicate the drop zone.
You will either get a leaveMsg or a filesMsg, so make sure the filesMsg
also clears any visual indication started by the enterMsg.
type Msg
= EnterDropZone
| LeaveDropZone
| FilesDropped (List File)
view =
Html.div
(dropZone
{ dataFormat = Base64
, enterMsg = EnterDropZone
, leaveMsg = LeaveDropZone
, filesMsg = FilesDropped
}
)
[ Html.text "Drop files here" ]
The result of a file reading operation