1

I have simple shiny app which run on my local PC and avaliable for users in my intranet. I tried to add button to choose folder.

Tried:

UI

library(shiny)
shinyUI(fluidPage(
                            actionButton("goButton","Choose folder"),
                            textOutput("session"))

)

Server

library(shiny)

shinyServer(function(input, output, session) {

  observe({
    if(input$goButton > 0){
      output$session <- renderText(function(){
        list.files(choose.dir())})
    }


  })

})

It works ok on my PC, but when someone use it in intranet(other PC) window to choose folder opens in my PC.

is there way to open choose folder on client PC?

Batanichek
  • 7,761
  • 31
  • 49
  • If you have the server running on your PC and others only open your UI from their own PC (without even having to install R), I don't think this can be done by R code. But you could add JavaScript to your UI which listens to your button click and sends the clients data back to your server. I'm not sure but this could be working. – K. Rohde Feb 12 '16 at 10:52
  • @K.Rohde Yes, others havent R installed. I tried find JavaScript solution but didnt find anything ( or i dont know how to implement it into shiny). ( add javascript to tags) – Batanichek Feb 12 '16 at 11:02
  • There are Shiny functions which send data directly to some `input$name` and vice versa you can add MessageHandlers in JavaScript that react to shiny. Check this website for more information. https://ryouready.wordpress.com/2013/11/20/sending-data-from-client-to-server-and-back-using-shiny/ – K. Rohde Feb 12 '16 at 12:12
  • @K.Rohde I know about it, but i cant find javascript version of folder chooser too. – Batanichek Feb 12 '16 at 12:15
  • I see... According to this: http://stackoverflow.com/questions/2809688/directory-chooser-in-html-page it can't be done for security reasons. The best you could do is workaround with shiny's `fileInput`. – K. Rohde Feb 12 '16 at 12:21

1 Answers1

2

Best option what i can find its library shinyFiles ( answer from RU_SO )

This package allow navigate throught server file system.

see shinyFilesExample()

But for me its work a bit slow and i plan to use simple dunamic selectInput with list.dirs(path = "some/path")

Community
  • 1
  • 1
Batanichek
  • 7,761
  • 31
  • 49