{"id":109,"date":"2008-02-29T14:19:03","date_gmt":"2008-02-29T19:19:03","guid":{"rendered":"http:\/\/stein.everybody.org\/brain\/download-multiple-files\/"},"modified":"2011-03-10T10:57:28","modified_gmt":"2011-03-10T15:57:28","slug":"download-multiple-files","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/download-multiple-files\/","title":{"rendered":"Download multiple files"},"content":{"rendered":"<p>To send multiple files to the web browser, embed the files in hidden iframes like this:<\/p>\n<pre>&lt;iframe id=\"file_download1\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"file1.zip\"\/&gt;\n&lt;iframe id=\"file_download2\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"file2.zip\"\/&gt;\n&lt;iframe id=\"file_download3\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"file3.zip\"\/&gt;<\/pre>\n<p>Or here&#8217;s a fun little page that demonstrates the technique with Javascript:<\/p>\n<pre>&lt;html&gt;\n  &lt;head&gt;\n    &lt;script language=\"javascript\"&gt;\n      function download(form) {\n\tfor(var i=0; i&lt;form.elements.length; i++) {\n\t  var element = form.elements[i];\n\t  if (element.type == \"checkbox\") {\n\t    if (element.checked) {\n\t      var iframe = document.createElement(\"iframe\");\n\t      iframe.width = iframe.height = iframe.frameBorder = 0;\n\t      iframe.scrolling = \"no\";\n\t      iframe.src = element.value;\n\t      document.getElementById(\"iframe_holder\").appendChild(iframe);\n\t    }\n\t  }\n\t}\n      }\n    &lt;\/script&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;form&gt;\n      &lt;input type=\"checkbox\" name=\"file1\" value=\"file1.zip\"\/&gt;file1.zip&lt;br\/&gt;\n      &lt;input type=\"checkbox\" name=\"file2\" value=\"file2.zip\"\/&gt;file2.zip&lt;br\/&gt;\n      &lt;input type=\"checkbox\" name=\"file3\" value=\"file3.zip\"\/&gt;file3.zip&lt;br\/&gt;\n      &lt;input type=\"button\" onclick=\"download(this.form)\" value=\"Download\"\/&gt;\n    &lt;\/form&gt;\n    &lt;div id=\"iframe_holder\"\/&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To send multiple files to the web browser, embed the files in hidden iframes like this: &lt;iframe id=&#8221;file_download1&#8243; width=&#8221;0&#8243; height=&#8221;0&#8243; scrolling=&#8221;no&#8221; frameborder=&#8221;0&#8243; src=&#8221;file1.zip&#8221;\/&gt; &lt;iframe id=&#8221;file_download2&#8243; width=&#8221;0&#8243; height=&#8221;0&#8243; scrolling=&#8221;no&#8221; frameborder=&#8221;0&#8243; src=&#8221;file2.zip&#8221;\/&gt; &lt;iframe id=&#8221;file_download3&#8243; width=&#8221;0&#8243; height=&#8221;0&#8243; scrolling=&#8221;no&#8221; frameborder=&#8221;0&#8243; src=&#8221;file3.zip&#8221;\/&gt; Or here&#8217;s a fun little page that demonstrates the technique with Javascript: &lt;html&gt; &lt;head&gt; &lt;script language=&#8221;javascript&#8221;&gt; function download(form) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,34],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-html","category-javascript"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}