The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: php file tupes help

  1. #1

    php file tupes help

    this php script scan mp3/a dir and creates xml file that reads flash and flash creats list of files and folders but it only wach(scan) mp3 files,but i want to scan any file tupe with this script how i can do this ?

    PHP Code:
    <?php
    $dir 
    "mp3/a/";



    echo 
    "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
    echo 
    "<music>\n";

    // Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if (
    $dh opendir($dir)) {
            while ((
    $file readdir($dh)) !== false) {
             
    $subdir $file;         
             if (
    $subdir != "." && $subdir != ".." && $subdir != "_notes") {
                echo 
    "<artist label=\"$subdir\" >\n";
                
    //Scan the subdirectories
                
    if ($sh opendir($dir $subdir."/")) {
                   while ((
    $sfile readdir($sh)) !== false) {
                   if (
    $sfile != "." && $sfile != "..") {
                      
    $pos strrpos($sfile".mp3");
                      
                      if (
    $pos) {
                         
    $subfile $sfile;
                         echo 
    "<song url=\"$dir$subdir/$subfile\" label=\"" str_replace(".mp3","",$subfile) . "\" />\n";
                    }
                      
                      }
                      
                   }
                   
    closedir($sh);
                
                }
                echo 
    "</artist>\n";         
             
             }         
             
            }
            
    closedir($dh);
        } 
    }
    echo 
    "</music>"
    ?>

  2. #2
    Change
    PHP Code:
                      $pos strrpos($sfile".mp3");
                      
                      if (
    $pos) {
                         
    $subfile $sfile;
                         echo 
    "<song url=\"$dir$subdir/$subfile\" label=\"" str_replace(".mp3","",$subfile) . "\" />\n";
                    } 
    to
    PHP Code:
                      
                         $subfile 
    $sfile;
                         echo 
    "<song url=\"$dir$subdir/$subfile\" label=\"" $subfile "\" />\n"
    got pwnt?

  3. #3
    thanks !!! it works thank u!!

  4. #4
    And is it posible to ad something like this $filetypes = array(".mp3",".mp4",".jpg"); in script and read file tupes only wich i want?and how i can do this can u help me again

  5. #5
    its inposible?

  6. #6
    ^If you had an array you would have to then have to use the "foreach" function. www.php.net
    Member #2 of the "I wont critique Timmytot's designs anymore" club.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012