larry29936 Posted June 17, 2020 Share Posted June 17, 2020 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? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 17, 2020 Share Posted June 17, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.