mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Update upload docs
This commit is contained in:
@@ -293,8 +293,25 @@ numericInput <- function(inputId, label, value, min = NA, max = NA, step = NA) {
|
||||
#' File Upload Control
|
||||
#'
|
||||
#' Create a file upload control that can be used to upload one or more files.
|
||||
#' \bold{Experimental feature. Only works in some browsers (primarily tested on
|
||||
#' Chrome and Firefox).}
|
||||
#' \bold{Does not work on older browsers, including Internet Explorer 9 and
|
||||
#' earlier.}
|
||||
#'
|
||||
#' 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:
|
||||
#' \describe{
|
||||
#' \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
|
||||
#' (see
|
||||
#' \code{datapath} column).}
|
||||
#' \item{\code{size}}{The size of the uploaded data, in
|
||||
#' bytes.}
|
||||
#' \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
|
||||
#' operation.}
|
||||
#' }
|
||||
#'
|
||||
#' @param inputId Input variable to assign the control's value to.
|
||||
#' @param label Display label for the control.
|
||||
|
||||
@@ -4,15 +4,15 @@ shinyServer(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 'data'
|
||||
# columns. The 'data' column will contain the local filenames where the data
|
||||
# can be found.
|
||||
# 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$data, header=input$header, sep=input$sep, quote=input$quote)
|
||||
read.csv(inFile$datapath, header=input$header, sep=input$sep, quote=input$quote)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
library(shiny)
|
||||
|
||||
shinyUI(pageWithSidebar(
|
||||
headerPanel("CSV Viewer"),
|
||||
headerPanel("Uploading Files"),
|
||||
sidebarPanel(
|
||||
fileInput('file1', 'Choose CSV File',
|
||||
accept=c('text/csv', 'text/comma-separated-values,text/plain')),
|
||||
|
||||
@@ -20,8 +20,23 @@
|
||||
}
|
||||
\description{
|
||||
Create a file upload control that can be used to upload
|
||||
one or more files. \bold{Experimental feature. Only works
|
||||
in some browsers (primarily tested on Chrome and
|
||||
Firefox).}
|
||||
one or more files. \bold{Does not work on older browsers,
|
||||
including Internet Explorer 9 and earlier.}
|
||||
}
|
||||
\details{
|
||||
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: \describe{ \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
|
||||
(see \code{datapath} column).} \item{\code{size}}{The
|
||||
size of the uploaded data, in bytes.}
|
||||
\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 operation.} }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user