Fetching contributors…
Cannot retrieve contributors at this time
103 lines (91 sloc) 3.2 KB
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/input-file.R
\title{File Upload Control}
fileInput(inputId, label, multiple = FALSE, accept = NULL, width = NULL,
buttonLabel = "Browse...", placeholder = "No file selected")
\item{inputId}{The \code{input} slot that will be used to access the value.}
\item{label}{Display label for the control, or \code{NULL} for no label.}
\item{multiple}{Whether the user should be allowed to select and upload
multiple files at once. \bold{Does not work on older browsers, including
Internet Explorer 9 and earlier.}}
\item{accept}{A character vector of MIME types; gives the browser a hint of
what kind of files the server is expecting.}
\item{width}{The width of the input, e.g. \code{'400px'}, or \code{'100\%'};
see \code{\link{validateCssUnit}}.}
\item{buttonLabel}{The label used on the button. Can be text or an HTML tag
\item{placeholder}{The text to show before a file has been uploaded.}
Create a file upload control that can be used to upload one or more files.
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:
\item{\code{name}}{The filename provided by the web browser. This is
\strong{not} the path to read to get at the actual data that was uploaded
\code{datapath} column).}
\item{\code{size}}{The size of the uploaded data, in
\item{\code{type}}{The MIME type reported by the browser (for example,
\code{text/plain}), or empty string if the browser didn't know.}
\item{\code{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
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
fileInput("file1", "Choose CSV File",
accept = c(
checkboxInput("header", "Header", TRUE)
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))
read.csv(inFile$datapath, header = input$header)
shinyApp(ui, server)
Other input elements: \code{\link{actionButton}},
\code{\link{checkboxInput}}, \code{\link{dateInput}},
\code{\link{dateRangeInput}}, \code{\link{numericInput}},
\code{\link{passwordInput}}, \code{\link{radioButtons}},
\code{\link{selectInput}}, \code{\link{sliderInput}},
\code{\link{submitButton}}, \code{\link{textAreaInput}},
\code{\link{textInput}}, \code{\link{varSelectInput}}
\concept{input elements}