Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using the same button to choose multiple files in different directories #189

Open
olechnwin opened this issue Dec 6, 2023 · 0 comments
Open

Comments

@olechnwin
Copy link

Hi,

I am trying to use the same button to choose multiple files that are in different directories. I was able to return the paths chosen when the button is clicked once. But when the button is clicked the second time, I tried to concat the paths to the existing one but it didn't work.

Here is a simple example of what I'm trying to do:

library(shinyFiles)

ui <- fluidPage(
 
 titlePanel("File Browser"),
 
 sidebarLayout(
  sidebarPanel(
   
   shinyFilesButton('files', label = 'Select', title = 'Please select a 
                       file', multiple = TRUE),
   verbatimTextOutput("filechosen")
  ),
  
  mainPanel(
  )
 )
)

r1.lst <- NULL
server <- function(input, output) {
 
 shinyFileChoose(input, 'files', root = c(root = '.'),
                 filetypes = c('',"txt"))
 
 file <- reactive(input$files)
 
 output$filechosen <- renderText({
  print(r1.lst)
  r1.lst <- c(r1.lst,as.character(parseFilePaths(c(root = "."),file())$datapath))
  print(r1.lst)
 })
 
}   
shinyApp(ui = ui, server = server)

The first time I clicked the select button, r1.lst contains the two paths I selected:

1] "raw_data/test.txt"
[2] "raw_data/test2.txt"

However, the second time, r1.lst becomes NULL again and the r1.lst contains only the new paths I selected:

1] "raw_data/diff_folder/test.txt"
[2] "raw_data/diff_folder/test2.txt"

How do I get all the files path selected in one list?

Thank you,
Cen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant