7

This may be very simple, but I cannot find the right syntax despite searching through postings:

I want to create a hyperlink on my shiny web page which when clicked should open a file from the same location where the application is.

Here is a sample code :

 library(shiny); 
 shinyApp( ui = fluidPage(a("test_hyperlink",href="./readme.txt")), 
           server = function(input, output) {  } )

readme.txt is in the same location as this application .

I tried the following with no success :

file://readme.txt # relative path
file:///srv/shiny-server/myApp/readme.txt # absolute path
href://./readme.txt # relative path
href:///srv/shiny-server/myApp/readme.txt # absolute path

Any help?

user227710
  • 3,164
  • 18
  • 35
Sri
  • 1,130
  • 1
  • 15
  • 31
  • 1
    For security reasons, most of the browsers wont allow linking to the local files. It works only if you enter the path manually into the url box. Good explanation here. https://answers.atlassian.com/questions/144386/how-to-link-local-folder – Shiva Jul 10 '15 at 18:57

1 Answers1

11

create a folder called 'www' inside your shiny app directory 'appFolder'.

Put the file 'readme.txt' in the www folder.

File path is href="readme.txt"

You have to use 'runApp(appFolder)' command to start your shiny app. It then can access all local files inside the www folder.

mingxue
  • 671
  • 6
  • 11