# Communication w php

**URL:** <https://forum.kirupa.com/t/communication-w-php/242858>\
**Category:** Uncategorized\
**Created:** [October 31, 2007, 1:55am UTC](https://forum.kirupa.com/t/communication-w-php/242858 "2007-10-31T01:55:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bed718](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bed718](https://forum.kirupa.com/u/bed718)\
**Post date:** [October 31, 2007, 1:55am UTC](https://forum.kirupa.com/t/communication-w-php/242858/1 "2007-10-31T01:55:31Z")

</div>

Hi,

I am trying to set up a dynamic flash gallery that will read the files inside a folder then use that data to populate the gallery.  
I’m almost done!

I would like the folder that the PHP code searches in to be loaded in from flash.

I have tried to use LoadVariables as in below:

```auto

var currentFolder:String = "folderPath"

_root.loadVariables( "pathtoPHPfile", "POST");

```

the php code looks like this…

```php

$folder = $_POST["currentFolder"];

function show_dir($dir, $pos=2) 
{ 
 if($pos == 2) 
     { 
        echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
";
		echo "<pics>
";
     } 

     $handle = @opendir($dir); 
     while ($file = @readdir ($handle)) 
     { 
        if (eregi("^\.{1,2}$",$file)) 
        { 
          continue; 
        } 

			$string = $file;
			$string_length = strlen($string);
			$firstpart = strtok($string,"_"); 
			$firstpart_length = strlen($firstpart); 
			$firstpart_length++; 
	
			$char_count = $string_length - $firstpart_length; 

			$final_part = substr($string,$firstpart_length,$char_count);
			echo " <pic>
";
			echo " <path>" . $file. "</path>
";
			echo " <title>" . $final_part. "</title>
";
			echo " </pic>
";
			
         	 
        
     } 
     @closedir($handle); 

     if($pos == 2) 
     { 
          echo "</pics>
"; 
     } 

} 

show_dir($folder);

```

If I hard code in the folder for the “show\_dir” funciton, everything works perfect… So, I dont think the problem is in show\_dir. However, if I try to load in the folder variable nothing happens. Seems like the variable is not getting from flash to the php script

any ideas at all?  
is there a better way to go about this??

any help would be great  
-=b=-  
[www.b-ed.com](http://www.b-ed.com)
