shiny upload file example: "Error: an error had occured. Check your logs or contact the app author for clarification"

Publish to shiny upload file, there will be an error, how to solve?


this is code

library(shiny)
shinyUI(fluidPage(
  titlePanel("File Input"),
  sidebarLayout(
    sidebarPanel(
      fileInput("file","Upload the file"),
      helpText("Default max. file size is 5MB"),
      tags$hr(),
      h5(helpText("Select the read.table parameters below")),
      checkboxInput(inputId = 'header',label = 'Header', value = FALSE),
      
      br(),
      radioButtons(inputId = 'sep' , label = 'Separator', choices = c(Comma=',',Semicolon=';',Tab='\t'),selected = ',')
      
      
    ),
    mainPanel(
      uiOutput("tb")
    )
  )
))
library(shiny)
#options(shiny.maxPequestSize = 9*1024^2)
shinyServer(
  function(input, output) {
    data <-reactive({
      file1 <- input$file
      if(is.null(file1)){return()}
      read.table(file =file1$datapath, sep=input$sep, header = input$header)
      
    })
    output$filedf <- renderTable({
      if(is.null(data())){return()}
      input$file
    })
    output$sum <- renderTable({
      if(is.null(data())){return()}
      summary(data())
    })
    output$table <- renderTable({
      if(is.null(data())){return()}
      data()
    })
    output$tb <- renderUI({
      if(is.null(data()))
        h5("Powered by", tags$img(src='S_8537261741698.png',heigth=100, width=120)) 
        else 
          tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data",tableOutput("table")),tabPanel("Summary",tableOutput("sum")))
    })
    
    
    
    
  })

Check logs at /var/logs/shiny-server/. R code produces an error, but on server-deployed apps all errors are replaced with standard message (my guess this is for security purposes).

Hi there, and welcome to community.rstudio.com! It's a little hard to help with only a screenshot to go on and no code. To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for debugging Shiny apps and creating a Shiny reprex can be found here.

I will echo what @ksavin has said about checking the logs - the user-facing error messages are pretty generic.

1 Like

From the URL in the screenshot, you appear to be using shinyapps.io. See the Debugging your application section of the documentation, in particular how to look at your logs.

Ok, the code has been pasted.


Can you help me?

Just by looking at the error log, I can see this error

"Error in gsub: input stgring 2 is invalid in this locale"

So perhaps that's the error that's breaking your app, if so, maybe one of the two solutions on this StackOverflow link can help https://stackoverflow.com/questions/41717781/warning-input-string-not-available-in-this-locale

Perhaps the error is something else, I'm just going by that error log screenshot without seeing the code