Upload files to the server.

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

Examples

### Standard file input fileInput(id = "file1")
#> <div class="yonder-file custom-file" id="file1"> #> <input type="file" class="custom-file-input" multiple autocomplete="off"/> #> <label class="custom-file-label" data-browse="Browse">Choose file</label> #> <div class="valid-feedback"></div> #> <div class="invalid-feedback"></div> #> </div>
### Adding a button fileInput( id = "file2", left = buttonInput("upload", "Upload") %>% background("green") )
#> <div class="yonder-file custom-file" id="file2" left="&lt;button class=&quot;yonder-button btn btn-green&quot; type=&quot;button&quot; role=&quot;button&quot; id=&quot;upload&quot; autocomplete=&quot;off&quot;&gt;Upload&lt;/button&gt;"> #> <input type="file" class="custom-file-input" multiple autocomplete="off"/> #> <label class="custom-file-label" data-browse="Browse">Choose file</label> #> <div class="valid-feedback"></div> #> <div class="invalid-feedback"></div> #> </div>
### Customizing text fileInput( id = "file3", placeholder = "Pick a file", browse = "Go go go!" )
#> <div class="yonder-file custom-file" id="file3"> #> <input type="file" class="custom-file-input" multiple autocomplete="off"/> #> <label class="custom-file-label" data-browse="Go go go!">Pick a file</label> #> <div class="valid-feedback"></div> #> <div class="invalid-feedback"></div> #> </div>