Hi guys,
I know that it might appear as a strange request but if you could help me I'll appreciate it.
Now the point is that I needed a script which would read the content of a folder storing some images for creating a gallery. I've used the following php script to read the directory:
<?php
$dir = "../images/".$cartella."/";
//$dir = 'path/to/the/directory';
$numfiles = 0;
if (is_dir($dir)) {
if ($openDir = opendir($dir)) {
while (false !== ($file = readdir($openDir))) {
if ($file != '.' && $file != '..') {
if (is_file($dir . '/' . $file)) {
$f = explode('.', $file);
$ext = array_pop($f);
if ($ext == 'jpg') {
echo "&filename$numfiles=$file";
++$numfiles;
}
}
}
}
}
closedir($openDir);
}
?>
At this point I needed to pass a variable called 'cartella' from flash which created the stumble point. After different tries I've came up with this solution :
var lv = new LoadVars();
lv.onLoad = function(ok) {
if (ok) {
var i = 0;
while (this["filename"+i] != undefined) {
trace(this["filename"+i]);
++i;
}
} else {
displai.htmlText += "ERROR";
}
};
cartella = "mock";
lv.load("flash/read.php?cartella="+cartella, "POST");
Now, don't take me bad for this, it works but somehow I don't feel fully satisfied with it. Could you have a look to the AS and point me which would have been the right way (if any) to write the code? Especially in the 'load' bit!
Thanks for your time
Giano