Shiny fileInput Does Not Keep File Name

Viewed 2672

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?

2 Answers
Related