我想使用 Shiny 创建一个 GUI 以将 5 个文件作为输入。上传这些文件后,我希望将它们保存在我知道目的地的特定文件夹中。我们可以这样做吗?如果是,如何?
谢谢你。
最佳答案
嗯,有点。您可以使用观察者在上传时复制文件:
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.rename
以避免在目标位于与临时目录不同的设备上时出现问题。
关于r - Shiny 的应用程序文件上传 : How can we save the files uploaded on a shiny GUI to a particular destination?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31966924/