Jump to content
larry29936

php block works in bootstrap but not non-bootstrap

Recommended Posts

I have the following php block that works on an existing bootstrap webpage:

      <?php 
      $isos = glob('download/*.iso');
      $iso = $isos[count($isos) -1];
      $isoname =  basename($iso);
      $isodown = "/".$isoname;
      $md5file = md5_file($iso);

       $pdfs = glob('download/foxcloneV*.pdf');
       $pdf = $pdfs[count($pdfs) -1]; 
       $pdfname = basename($pdf);
     
       $debs = glob('download/*.deb');
       $deb = $debs[count($debs) - 1];
       $debname =  basename($deb);;                   
      
       $srcs = glob('download/*.tar.*');
       $src = $srcs[count($srcs) - 1];
       $srcname = ltrim($src,'download/');                   
     ?>

 

When I try to use it in a non-bootstrap website, it fails with the following errors:

Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 104

Warning: md5_file(): Filename cannot be empty in /home/larry/web/test2/public_html/download.php on line 106

Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 109

Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 113

Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 117

 

Each of these failures is the line after the glob. Is the glob failing or is the syntax wrong for non-bootstrap use? Either way, my thinking is that php should behave the same regardless of what the base model for the website is. Both the bootstrap and non-bootstrap sites are running locally under apache2.4 and php7.2.

Can someone provide some insight? 

Share this post


Link to post
Share on other sites

the warnings and notices are from php. they have nothing to do with with any framework the site is using for the presentation of information.

the glob() is not matching any files and your code should test ( !empty($var)  would work) before trying to access any of the results and output an appropriate message if no matching file was found.

as to why the glob calls are failing, it would either be due to a problem with the spelling, capitalization, actual path being used, or there are no matching files inside the folders.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.