Learn R Programming

yonder (version 0.1.0)

fileInput: Upload user files

Description

Upload files to the server.

Usage

fileInput(id, placeholder = "Choose file", browse = "Browse",
  left = NULL, right = NULL, ..., 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".

left, right

A character string or button element placed prepended or appended respectively to the file input. For more information refer to groupInput().

Clicking on an element specified by right also opens the file input dialog.

...

Additional named arguments passed as HTML attributes 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.

<strong>Example</strong> uploading a file

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

print(input$upload) }) } )

Details

Be careful when adjusting the right or left margin of a file input. In the current version of Bootstrap file inputs can be pushed off the side of a page.

See Also

Other inputs: buttonGroupInput, buttonInput, checkboxInput, chipInput, formInput, groupInput, listGroupInput, menuInput, navInput, radioInput, rangeInput, selectInput, sliderInput, textInput

Examples

Run this code
# NOT RUN {
### 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!"
)

# }

Run the code above in your browser using DataLab