我正在用 Shiny 编写一个程序,用户可以在其中上传文件并将其保存到指定的文件夹中。执行此操作的方法取自 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")
})
})
)
当我执行此操作时,我发现该文件在保存到指定文件夹时删除了文件名。读取文件夹中文件的程序要求保留文件名。我怎样才能做到这一点?
最佳答案
将 file.copy 行更改为
file.copy(input$upload$datapath, paste0("your_folder/", input$upload$name))
关于r - Shiny 的 fileInput 不保留文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36144499/