Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

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