# Flash/PHP sendAndLoad result complete gibberish

**URL:** <https://forum.kirupa.com/t/flash-php-sendandload-result-complete-gibberish/180875>\
**Category:** flash\
**Created:** [March 4, 2006, 2:40am UTC](https://forum.kirupa.com/t/flash-php-sendandload-result-complete-gibberish/180875 "2006-03-04T02:40:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blindart](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@blindart](https://forum.kirupa.com/u/blindart)\
**Post date:** [March 4, 2006, 2:40am UTC](https://forum.kirupa.com/t/flash-php-sendandload-result-complete-gibberish/180875/1 "2006-03-04T02:40:58Z")

</div>

[LEFT]How-do! I’ve searched the forums, but haven’t found the answer to my current headache, Please help! :puzzled:

I want to use a php file to return the contents of a specified directory, then (in flash) create an array of filenames that can be used to build a gallery.

The php file works fine when I test it in my browser, and the AS says its being read OK, but its contents are absolute nonsense! This is what I have so far…

> 

```auto
toPHP = new LoadVars();
fromPHP = new LoadVars();

fromPHP.onLoad = function(success) {
    trace(this);
    //trace(images = fromPHP.split(","));
}
    toPHP.gallery="./gallery/3D/";
    toPHP.sendAndLoad("_getDir.php",fromPHP,"POST");

```

and the php…

> 

```php
<?php
    $dir_name = $_POST['gallery'];
    //$dir_name = './assets/personal/';
    $dir = opendir($dir_name);
    $file_list = "fileList=";
    while ($file_name = readdir($dir))
    {
        if (($file_name != ".") && ($file_name != ".."))
        {
                $file_list .= $dir_name+$file_name+",";
        }
    }
    closedir($dir);
    echo $file_list;
?> 

```

Please help! I thought the hard bit would be reading the directory contents with php, not getting the info back into Flash!! \<sigh\> I was wrong.

[/LEFT]
