How to reset a value of fileInput in Shiny?

前端 未结 2 1318
盖世英雄少女心
盖世英雄少女心 2021-02-15 10:50

There are already similar posts on this matter (ex. how can I update a shiny fileInput object?), but I still cannot figure out how one may force Shiny to forget a value of

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-15 11:52

    I know this is an old post, but you can reset the input by rebuilding it from scratch in the server.

    In ui.R you can put:

    ...
    uiOutput('file1_ui') ## instead of fileInput('file1', label = NULL)
    ...
    

    And in server.R add this:

    ...
    output$file1_ui <- renderUI({
      input$reset ## Create a dependency with the reset button
      fileInput('file1', label = NULL)
    })
    ...
    

提交回复
热议问题