获取AS3文件夹中的文件数

I made a flash webpage with a file-upload system for uploading pdf's to a subfolder in the same folder where the swf is hosted. I want to make a very simple system to count the number of files in that folder from inside the AS3 of the main webpage (with the purpose of displaying it somewhere in the flash page..). I still haven't found a straight answer on how to do it (or if it's even possible). I think that maybe i have to use an additional php script to count the files..

Any idea is welcome! Thx in advance!

You will need a server-side script. For example, using PHP you can use scandir() to read the files and json_encode() to output it as JSON. For example:

// scandir.php
echo json_encode(scandir("path/to/dir"));

Then you simply load the JSON from AS3 using URLLoader. For example:

var urlLoader:URLLoader = new URLLoader(new URLRequest("http://path/to/scandir.php"));
urlLoader.addEventListener(Event.COMPLETE, complete);
function complete(e:Event):void {
        var files:Array = JSON.parse(urlLoader.data);
        trace(files.length);
});