fileInput to receive full path name

973 views
Skip to first unread message

Amitoj Chopra

unread,
Feb 28, 2017, 5:22:52 PM2/28/17
to Shiny - Web Framework for R
Hi All,
I am creating a UI interface through shiny that will ask for a file input.
I am using the fileInput function as shown below. I am asking for a file (xml type) and then running it through my function called checker.
Then I am displaying the summary of the script running.
I had a question about how do I get the full path name from fileInput. Currently i get a temp directory. I would like the full path name so I can do some manupluations. I would like to save the file the entire directory that the file is in. I can do it using a command line command but I need the full path name.
Here are my scripts, if you had any questions feel free to ask me.

UI.R:

library(shiny)

-----------------Start-----------------------
# Define UI for dataset viewer application
shinyUI(fluidPage(
  
  # Application title.
  headerPanel("Cluster Density Checker"),
  
  sidebarPanel(
    
    fileInput("inputId", "Please Pick Run Completion.xml File",accept=c("XML", "text/comma-separated-values,text/plain", ".XML")),
    
    
    submitButton("Run Analysis")

  ),
  mainPanel(
    h4("Summary"),
    verbatimTextOutput("summary")
    
    
    
  )
))
-----------------End-----------------------

Server.R:
source(some file with checker function)

shinyServer(function(input, output) {
  
  
  

  
    output$summary = renderPrint({
    if(is.null(input$inputId)) {return()}
    if(!input$inputId == 0){
    data.out = checker(
    input$inputId$data.path)
    
    
       }
      

})

Luis Galiano

unread,
Mar 1, 2017, 3:41:29 PM3/1/17
to Shiny - Web Framework for R

This is how I've been proceeding when I need to rebuild the original file (get path and place the original name back):

if(!is.null(input$fileOpen)){
      inFile <- input$fileOpen
      old_name <- inFile$datapath
      dirstr <- dirname(inFile$datapath)
      new_name <- paste(dirstr, inFile$name,sep="/")
      file.rename(old_name, new_name)
      # Do whatever else you need to do.. copy... load...
Reply all
Reply to author
Forward
0 new messages