I'm trying to upload an image and then save it to the server file system using Shiny.
To upload I've found
fileInput
which creates a data.frame containing the image details and datapath. How then can this be used to save to a remote server?
Here is basic example. It only copy the uploaded file to at location on server. In this is in the same computer, but it could be anywhere.
library(shiny)
shinyApp(
ui = shinyUI(
fluidRow(
fileInput("myFile", "Choose a file", accept = c('image/png', 'image/jpeg'))
)
),
server = shinyServer(function(input, output,session){
observeEvent(input$myFile, {
inFile <- input$myFile
if (is.null(inFile))
return()
file.copy(inFile$datapath, file.path("c:/temp", inFile$name) )
})
})
)
shinyApp(ui, server)
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