I am working on a shiny app that allows the user to download an existing .csv
file (called template.csv
) that is located on the server (in a folder called "data").
Using downloadHandler
, I do not get any output.
library(shiny)
ui <- fluidPage(
downloadButton("download", label = "Download")
)
server <- function(input,output) {
output$download <- downloadHandler(
filename <- function() {
"template_output.csv"
}
content <- function(file) {
file.copy("./data/template.csv", file)
}
}
shinyApp(ui = ui, server = server)
Where did I go wrong? Can someone help me make it work? Thanks a lot!
Please try the below:
library(shiny)
ui <- fluidPage(
downloadButton("download", label = "Download")
)
server <- function(input,output) {
output$download <- downloadHandler(
filename <- function() {
"template_output.csv"
},
content <- function(file) {
file.copy("./data/template.csv", file)
}
)
}
shinyApp(ui = ui, server = server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.