This module exposes attributes that you can use to read files into Elm.
Add these attributes to an input node to get the contents of the selected file.
type Msg
= FileSelected File
view =
Html.input (fileInput 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 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
{ enterMsg = EnterDropZone
, leaveMsg = LeaveDropZone
, filesMsg = FilesDropped
}
)
[ Html.text "Drop files here" ]
A selected file that has been read into the application. The file contents are in the form of a data URL as specified by RFC 2397.
lastModifiedis of typeMaybe Timebecause not all browsers and situations will give you a last modified field.