0

////////////////////// Solution //////////////////////

There was a problem with my syntax, I was using + instead of . to concatenate Music/ and $file.

require ('getid3/getid3.php');


         $getID3 = new getID3;


            if ($handle = opendir('Music/')) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {


                //echo $file;



                $ThisFileInfo = $getID3->analyze("Music/".$file);

                // Delete temporary file

                echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
                print_r ($ThisFileInfo);
                echo   '</li>' ;
                }
            }
closedir($handle);



            }

///////////////////////// Problem ////////////////////////

The short explanation is this loop is supposed to extract meta data and print it to the page with the download link. It will do this as many times as there are files in the listed directory. The loop works perfectly, however the array is not extracting the meta data. I have it running locally on an xampp server.

        require ('getid3/getid3.php');


         $getID3 = new getID3;


            if ($handle = opendir('Music/')) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {

                //echo $file;


                $ThisFileInfo = $getID3->analyze("Music/ " + $file);

                // Delete temporary file

                echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
                print_r ($ThisFileInfo);
                echo   '</li>' ;
                }
            }
closedir($handle);

    }

This is what I get on the page.

Lunar_2_Blue_Star_Prayer_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) ) Retro_City_Rampage_Retrohead_Five_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) ) Super_Mario_RPG_The_Usurper_Queen_OC_ReMix.mp3 Array ( [GETID3_VERSION] => 1.9.12-201602240818 [error] => Array ( [0] => Could not open "0" (!is_readable; !is_file; !file_exists) ) )

file structure more structure

  • I think there's a problem with permissions on folder. What permissions do you have on folder? – Sakezzz Feb 24 '17 at 15:36
  • I didn't set any. It's just running on an XAMMP server, – jackthemayor Feb 24 '17 at 15:44
  • I get the same results running on a test server. – jackthemayor Feb 24 '17 at 16:39
  • Are you sure that directory exists? Try [__DIR__](http://php.net/manual/en/language.constants.predefined.php) – Sakezzz Feb 24 '17 at 17:01
  • I posted a couple of caps of the root folder and the folder where the mp3 files live. The directory would have to exist otherwise I would not get any of the file names. The main issue is I am not getting any meta tags, which is what is causing the error. I get all the filenames and it prints the file names out in a loop correctly. – jackthemayor Feb 24 '17 at 17:41
  • Solved it was an issue with the way the variable was concatenating to the directory. Thanks for helping. – jackthemayor Feb 24 '17 at 18:34
  • @jackthemayor If this question is answered, please create an answer and mark that as accepted. – cwallenpoole Feb 24 '17 at 18:52

1 Answers1

0

////////////////////// Solution //////////////////////

There was a problem with my syntax, I was using + instead of . to concatenate Music/ and $file.

require ('getid3/getid3.php');

     $getID3 = new getID3;


        if ($handle = opendir('Music/')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {


            //echo $file;



            $ThisFileInfo = $getID3->analyze("Music/".$file);

            // Delete temporary file

            echo '<li><a href=" Music/'.$file.'">'.$file.'</a>  <br>';
            print_r ($ThisFileInfo);
            echo   '</li>' ;
            }
        }

closedir($handle);

        }