Description Usage Arguments Details See Also Examples
Create a file upload control that can be used to upload one or more files.
1 |
inputId |
The |
label |
Display label for the control, or |
multiple |
Whether the user should be allowed to select and upload multiple files at once. Does not work on older browsers, including Internet Explorer 9 and earlier. |
accept |
A character vector of MIME types; gives the browser a hint of what kind of files the server is expecting. |
width |
The width of the input, e.g. |
Whenever a file upload completes, the corresponding input variable is set to a dataframe. This dataframe contains one row for each selected file, and the following columns:
name
The filename provided by the web browser. This is
not the path to read to get at the actual data that was uploaded
(see
datapath
column).
size
The size of the uploaded data, in bytes.
type
The MIME type reported by the browser (for example,
text/plain
), or empty string if the browser didn't know.
datapath
The path to a temp file that contains the data that was uploaded. This file may be deleted if the user performs another upload operation.
Other input.elements: actionButton
,
checkboxGroupInput
,
checkboxInput
, dateInput
,
dateRangeInput
, numericInput
,
passwordInput
, radioButtons
,
selectInput
, sliderInput
,
submitButton
, textInput
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
tableOutput("contents")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, it will be a data frame with 'name',
# 'size', 'type', and 'datapath' columns. The 'datapath'
# column will contain the local filenames where the data can
# be found.
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header)
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.