fileInput Download the file directly, so I suggest you create your own "fileInput".
Here's how I proceed:
Server.R
library(shiny) shinyServer(function(input, output, session) { observe({ if (input$browse == 0) return() updateTextInput(session, "path", value = file.choose()) }) contentInput <- reactive({ if(input$upload == 0) return() isolate({ writeLines(paste(readLines(input$path), collapse = "\n")) }) }) output$content <- renderPrint({ contentInput() }) })
Ui.r
library(shiny) shinyUI(pageWithSidebar( headerPanel("Example"), sidebarPanel( textInput("path", "File:"), actionButton("browse", "Browse"), tags$br(), actionButton("upload", "Upload Data") ), mainPanel( verbatimTextOutput('content') ) ))
In Server.R, we first update the text input value each time we click the Browse action button.
"contentInput" is a reactive function, it will be reinstalled when the input values ββ(contained in the function body) are changed, "enter $ upload" here, and not when the "input $ path" has changed, because we isolate it, If we isolate If you donβt isolate the part containing the "input path $ path", the "contentInput" will be reinstalled every time we view a new file, and then the download button will be useless here.
And then we return the result of "contentInput" to "output $ content".
I hope for this help.
EDIT ##:
I realized that if you deselect the file, it will lead to an error and glitter of the application, then you should use this function by Henrik Bengtson ( https://stat.ethz.ch/pipermail/r-help/2007-June/133564.html ):
file.choose2 <- function(...) { pathname <- NULL; tryCatch({ pathname <- file.choose(); }, error = function(ex) { }) pathname; }