# Is it possible?

**URL:** https://forum.kirupa.com/t/is-it-possible/33904
**Category:** Uncategorized
**Created:** [October 24, 2003, 10:57pm UTC](https://forum.kirupa.com/t/is-it-possible/33904 "2003-10-24T22:57:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Uli](https://avatars.discourse-cdn.com/v4/letter/u/ccd318/32.png) [@Uli](https://forum.kirupa.com/u/Uli)
#### Post date: [October 24, 2003, 10:57pm UTC](https://forum.kirupa.com/t/is-it-possible/33904/1 "2003-10-24T22:57:28Z")

</div>

Hello

I was wondering if it’s possible from flash to check for files at the same level as where the flash movie is. I was thinking of making a dynamic playlist depending on what mp3 there’s on the webserver in the same dir as the movie.swf.

Can anyone guide me? Is it possible?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 25, 2003, 3:09am UTC](https://forum.kirupa.com/t/is-it-possible/33904/2 "2003-10-25T03:09:39Z")

</div>

Hmm… I’m not too sure about Flash being able to read directory structures (but I definatly don’t know everything about flash).

My suggestion would be to use your favorite server-side scripting language (PHP, PERL, ASP, etc) to search for the MP3s in a specific dir and then pass the results to flash via the new LoadVars class :).

Here is a PHP script that will read all the files in a specified directory and if they are an MP3 will out put a flash-formated string of text that can be loaded via the LoadVars class or getURL or the LoadVars function.

```php

<?php
	   	//starting directory
    	$startDir = "/home/httpd/htdocs/";
		//count for flash array
		$count = 0;
    	//open directory
    	$openDir = opendir($startDir);
    	//loop while there are still things to be read in directory
    	while($path = readdir($openDir))
    	{
    		//gets the base name of file i.e instead of /home/music/blah.mp3 its blah.mp3
    		$file = basename($path);
    		//makes sure we dont we read the . and .. direcotry (current directory and parent directory)
    		if($file!="." && $file!="..")
    		{ 
    			//if its not a directory print out the stats (can be changed for your needs)
    			if(!is_dir($startDir."/".$file)){
					//Make sure file is MP3
					$file_ext = substr($file, strlen($file)-3, 3);
					if($file_ext == "MP3" or $file_ext == "mp3"){
						if($count != 0){ print "&"; }
						print "mp3Files[$count]=".urlencode("$file");
						$count++;
					}
    			} //end if
    		} //end if
    	} //end while
?>

```

That is what I usually do when I do MP3 playlists, hope this helps.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 25, 2003, 4:06pm UTC](https://forum.kirupa.com/t/is-it-possible/33904/3 "2003-10-25T16:06:54Z")

</div>

thanks i will give it a look :} :}
