I can upload the .pdf file locally to my www/ folder, but when I try to display the newly uploaded file, it says it's "Not Found".
I'll paste my files here, and a screenshot of what it looks like from a webpage.
server.R
library(shiny)
#CMD+SHIFT+ENTER to run app
myServer <- function(input, output, session) {
observe({
req(input$file_input)
file.copy(input$file_input$datapath, paste0("www/", input$file_input$name), overwrite = T)
output$pdfview <- renderUI({
tags$iframe(style="height:600px; width:100%", src=paste0("www/", input$file_input$name))
})
})
}
ui.R
library(shiny)
myUI <- fluidPage(
titlePanel("Testing File upload"),
sidebarLayout(
sidebarPanel(
fileInput('file_input', 'upload file ( . pdf format only)', accept = c("application/pdf", ".pdf"))
),
mainPanel(
uiOutput("pdfview")
)
)
)
app.R
library(shiny)
source("ui.R", local = TRUE)
source("server.R")
shinyApp(
ui = myUI,
server = myServer
)
shinyApp(ui, server)
I can go to my file folder and open the uploaded files and they have content and open in the browser. I have my R files outside of my www/ folder. I tried to do the localhost url instead of opening from www/, but I didn't understand the difference and "localhost wouldn't connect"
Thank you in advance :)
