Reputation: 37
I want to create a GUI using shiny to take 5 files as an input. Once I have uploaded these files, I want them to be saved in a particular Folder whose destination is known by me. Can we do this? If yes, how? Thank You.
Upvotes: 3
Views: 7668
Reputation: 250
In addition to the answer by zero323, Use file.copy
as below if you want to overwrite the old uploads with new ones during each re-run of your app:
file.copy(..., recursive= TRUE)
(I wanted this in my app but it took me a whole lot of time to figure this out as I was a newbie at this)
Upvotes: 3
Reputation: 330313
Well, kind of. You can use observer to copy the file on upload:
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")
})
})
)
Not that I am using file.copy
and not file.rename
to avoid problems when the destination is located on a different device than the temporary directory.
Upvotes: 11