PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Unsolved

How to code HTML download button where filename version will change

larry-hale

Mar 15th, 2020 12:17 PM

I'm creating a webpage where the user will be able to download an .iso file. The version of the iso will change. For example: xxxx.1.iso will become xxxx.2.iso when the iso is updated. How do I code the download button so that I don't need to re-code the button when the version changes. If I were to create a download subdirectory, and the .iso file was kept there do you think this would work if the only file in the download subdirectory is the .iso file?

  <?php
    $files = array_slice(scandir('/download/'), 2); 
    ?>         
    <div class="navbar-custom">
       <a class="btn-solid-lg page-scroll" href="/Download/" download=$files>Download the App</a>
    </div>
larry-hale

Mar 15th, 2020 08:44 PM

I've tried the following method but it immediately downloads index.html and the site never loads in the browser.

        <?php
                $files = array();
                foreach (glob("/download/*.iso") as $file) {
                  $files[1] = $file;
                }
                $file2 = "window.location.href = 'https://foxclone.com/download/' + '$file'" 
           ?>
            <div class="navbar-custom">
                <button onclick="$file2" >Download the App</button>