# Accept CSV files only
calcite_input_file(
id = "my_file",
accept = "csv",
label_text = "Upload a CSV file"
)
# Accept multiple image formats
calcite_input_file(
id = "my_file",
accept = c("png", "jpg", "jpeg", "gif"),
multiple = TRUE,
label_text = "Upload images"
)
if (interactive()) {
library(shiny)
ui <- calcite_shell(
calcite_panel(
heading = "File Upload",
calcite_input_file(
id = "csv_upload",
accept = "csv",
label_text = "Upload CSV"
),
tableOutput("contents")
)
)
server <- function(input, output, session) {
output$contents <- renderTable({
req(input$csv_upload)
read.csv(input$csv_upload$datapath[1])
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab