php – In html how do I get the filename of the only .iso file in the download folder on the server and use the filename in a button.onclick event?-ThrowExceptions

Exception or error:

I’m new to web development so please excuse what might be a confusing description of what I’m trying to accomplish.

On the server, my website is located in the public_html folder under my domain. In public_html, I have a download folder which has an xxxx.yy.iso file, where yy (version number) will change based on new release number. There will never be more than one .iso in the download folder. I need to use the filename in both a “button onclick….” event and in an announcement on the download page.

I need some input on how best to accomplish the retrieval of the filename that is usable for both purposes. Would it be easier to have a version.txt file and read its content rather then trying to get the filename of the .iso file, seeing as the filename to read (of version.txt) then never changes?

EDIT: I’ve tried the following code but it’s not working. Does anyone see where the problem is?

      <?php
        $files = array();
        $files = glob('download/*.iso');
        $file2 = "window.location.href = 'https://foxclone.com/'".$files[0];
      ?> 

    <div class="navbar-custom">
       <button onclick="<?php echo $file2;?>">Download the App</button>
    </div>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *