I am writing a program in Shiny where the user uploads a file and it saves to a specified folder. The method to do this is taken from this question's answer.
library(shiny)
shinyApp(
ui=shinyUI(bootstrapPage(
fileInput("upload", "Upload", multiple = FALSE)
)),
server=shinyServer(function(input, output, session){
observe({
if (is.null(input$upload)) return()
file.copy(input$upload$datapath, "/some/other/path")
})
})
)
When I execute this, I find that the file has its file name stripped when it is saved to the specified folder. The program that reads the files in the folder requires that the file name is left in tact. How can I accomplish that?
Change the file.copy line to
file.copy(input$upload$datapath, paste0("your_folder/", input$upload$name))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With