I really need an help for this as I'm totally lost and I tred all I could find around. I have a selectInput and I need to load a table for each of the possible choices. Unfortunately when I use the same file for two consecutive choices, the inputfile is not triggered and I cannot load the file for the second time. I cannot believe I'm the first who's tackling this... That's what I found around as possible solution but it seems not to work how can I update a shiny fileinput
Any hint will be more than welcome
library(shiny)
runApp(list(
ui = bootstrapPage(
tags$script('Shiny.addCustomMessageHandler("resetFileInputHandler", function(x) {
var el = $("#" + x);
el.replaceWith(el = el.clone(true));
var id = "#" + x + "_progress";
$(id).css("visibility", "hidden");
});'
),
sidebarPanel(
fileInput("file1", NULL, width="80%"),
selectInput('uploadFormat', label = "Select upload format",
choices = c(
"Option 1" = 'f1',
"Option 2" = 'f2',
"Option 3" = 'f3'),
selected = 'f1')
),
mainPanel(
verbatimTextOutput("summary"),
uiOutput("Table")
)
),
server = function(input, output, session) {
userEnv <- new.env()
userEnv$tablecsv <- NULL
observe({
input$file1
input$uploadFormat
f <- input$uploadFormat
if (!is.null(input$file1))
if (is.null(userEnv$tablecsv[[f]]))
(userEnv$tablecsv[[f]] <- read.table(input$file1$name, header = FALSE, sep=";", dec="."))
session$sendCustomMessage(type = "resetFileInputHandler", "file1")
T <- userEnv$tablecsv[[f]]
output$Table <- renderTable({T})
})
output$summary <- renderText({
return(paste("Uploaded file: ", input$file1$name))
})
}
))