fileInput: File inputs

Description Usage Arguments Example uploading a file See Also Examples

View source: R/file.R

Description

Upload files to the server.

Usage

1
2
3
4
5
6
7
8
fileInput(
  id,
  placeholder = "Choose file",
  browse = "Browse",
  ...,
  multiple = TRUE,
  accept = NULL
)

Arguments

id

A character string specifying the id of the reactive input.

placeholder

A character string specifying the text inside the file input, defaults to "Choose file".

browse

A character string specifying the label of file input, defaults to "Browse".

...

Additional named arguments passed as HTML attributes to the parent element or tag elements passed as child elements to the parent element.

multiple

One of TRUE or FALSE specifying whether or not the user can upload multiple files at once, defaults to TRUE.

accept

A character vector of possible MIME types or file extensions, defaults to NULL, in which case any file type may be selected.

Example uploading a file

shinyApp(
  ui = container(
    fileInput("upload") %>%
      margin(0, "auto", 0, "auto")
  ),
  server = function(input, output) {
    observe({
      req(input$upload)

      print(input$upload)
    })
  }
)

See Also

Other inputs: buttonGroupInput(), buttonInput(), checkbarInput(), checkboxInput(), chipInput(), formInput(), listGroupInput(), menuInput(), navInput(), radioInput(), radiobarInput(), rangeInput(), selectInput(), textInput()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
### Standard file input

fileInput(id = "file1")

### Adding a button

fileInput(
  id = "file2",
  left = buttonInput("upload", "Upload") %>%
    background("green")
)

### Customizing text

fileInput(
  id = "file3",
  placeholder = "Pick a file",
  browse = "Go go go!"
)

yonder documentation built on Jan. 11, 2020, 9:35 a.m.