Flash/PHP sendAndLoad result complete gibberish

[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…

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
    $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]