title: Shiny R Zip multiple PDFS for download
body: <p>I am sorry if this too simple... I need to zip a number of generated pdfs for uses to download. I tried to use <code>Zip</code> function, but failed with error:</p>
  
  <pre><code>Warning: running command '"zip" -r9X "pdfs.zip" "plot_1.pdf" "plot_2.pdf" "plot_3.pdf" "plot_4.pdf" "plot_5.pdf" ' had status 127
  Error opening file: 2
  Error reading: 6
  </code></pre>
  
  <p>Below is my code and any suggestions are welcomed (based on <a href="https://stackoverflow.com/questions/25247852/shiny-app-disable-downloadbutton?answertab=votes#tab-top">shiny app : disable downloadbutton</a>) :</p>
  
  <p>UI.R</p>
  
  <pre><code>library(shiny)
  
  shinyUI(fluidPage(
    singleton(tags$head(HTML(
  '
    &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
        // disable download at startup. data_file is the id of the downloadButton
        $("#data_file").attr("disabled", "true").attr("onclick", "return false;");
  
        Shiny.addCustomMessageHandler("download_ready", function(message) {
          $("#data_file").removeAttr("disabled").removeAttr("onclick").html(
            "&lt;i class=\\"fa fa-download\\"&gt;&lt;/i&gt;Download " + message.fileSize + " ");
        });
      })
    &lt;/script&gt;
  '
  ))),
    tabsetPanel(
      tabPanel('Data download example',
        actionButton("start_proc", h5("Click to start processing data")),
        hr(),
  
        downloadButton("data_file"),
        helpText("Download will be available once the processing is completed.")
      )
    )
  ))
  </code></pre>
  
  <p>Server UI.R</p>
  
  <pre><code>library(shiny)
  
  get_a_pdf_plot &lt;- function(my_i){
        pdf(paste("plot_", my_i, sep=""))
        plot(1:my_i*5, 1:my_i*5,
             xlim = c(1, my_i*5),
             ylim = c(1, my_i*5),
             main = paste("1:", my_i, sep = ""))
        dev.off()
  }
  
  
  shinyServer(function(input, output, session) {
  
    observe({
      if (input$start_proc &gt; 0) {
        Sys.sleep(2)
        session$sendCustomMessage("download_ready", list(fileSize= "Ready"))
      }
    })
  
    output$data_file &lt;- downloadHandler(
         filename = 'pdfs.zip',
         content = function(fname) {
          fs &lt;- c()
          tmpdir &lt;- tempdir()
          setwd(tempdir())
          print (tempdir())
  
          for (i in c(1,2,3,4,5)) {
            path &lt;- paste("plot_", i, ".pdf", sep="")
            fs &lt;- c(fs, path)
            get_a_pdf_plot(i)
          }
          print (fs)
          zip(zipfile="pdfs.zip", files=fs)
         }
    )
  })
  </code></pre>