0

I've been making an app in shiny, and it is meant to use/edit the same file for multiple different people.

The idea is that when you open the app for the first time, it'll prompt you to select the file, and save the location of the file so you don't have to select it every time you open the program.

I can't seem to find a way to do this, only saving edits to the file. Is there a way, or would you just have to select the file every time?

EDIT: here is some simple code to give you an idea of what i've been working with

library(shiny)
setwd("~/myfiles")

ui <- fluidPage(
  fileInput("user_file", "Please enter a file"),
  textOutput("txt_param")
)

server <- function(input, output, session) {
  file_path <- input$user_file$datapath

  output$txt_param <- renderText(as.character(input$user_file$datapath))

  ### Store the file's path in a csv to access later ###
  as.data.frame(file_path)
  write.csv(file_path, "user_file_path.csv")
}

shinyApp(ui, server)
  • Are you trying to save the file on the server? Browser security keeps you from accessing any files on a web page without actually choosing them directly each time. What exactly did you try? It would be best to share some sort of minimal [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that can be used for testing. – MrFlick Jul 11 '18 at 17:46
  • I tried using fileInput, but it looks like the path to the files is temporary, so I couldn't get the actual file's path – Matthew Rogers Jul 11 '18 at 17:53
  • You've have to move it from the temporary location given by the `fileInput` to somewhere more permanent. Then you can check that location on startup to see if a file is already there. – MrFlick Jul 11 '18 at 18:19
  • Find your answer here: https://stackoverflow.com/questions/46118367/using-shiny-fileinput-to-get-path-only – Jan Feb 14 '21 at 09:04
  • 2
    Does this answer your question? [Using Shiny fileInput to get path only](https://stackoverflow.com/questions/46118367/using-shiny-fileinput-to-get-path-only) – Jan Feb 14 '21 at 09:06

0 Answers0