PDA

View Full Version : Getting a list of all *.jpg in a directory + pass to flash?


Durnus
04-02-2008, 03:26 AM
I'm new to server side scripting, but I need it now. (Sorely. :p)

What I need to do is use AS3 to load a php page, which tells my flash all of the filenames in a certain directory. How would I do that? I don't know how to write this .php, nor do I know how to make it accessible by Flash. I would just need some sort of string passed with delimeters such as |, which could be interpreted by flash to give me an array of all the filenames.

I hope someone can help me with this... in exchange for all the help I give to people... :p

;)

Cota
04-02-2008, 03:34 AM
Here's a quick version of the PHP to read the directoy

<?php

$path = "/image";
$files = "";

if ($handle = opendir($path)) {
while (false !== ($files .= readdir($handle))) {
$files .= "|";
}

closedir($handle);
echo "&fileList=".$files;
}
?>

Durnus
04-02-2008, 03:41 AM
Doesn't seem to work for me, landed me with a

"500 Internal Server Error

The server has encountered an internal error or misconfiguration and was unable to complete your request."

But now I know how to get that into flash. :D (Already figured it out, but forgot I had.)


EDIT: Sorry, forgot to say thanks. :rolleyes:

Durnus
04-02-2008, 04:08 AM
Okay, I figured out how to use it, using the following code:


<?

$root = "../images/unzipped/";
if(is_dir($root))
{
if($dir = opendir($root))
{
while($file = readdir($dir))
{
if(strpos($file, ".jpg") != FALSE)
{
$exif = exif_read_data($file, 0, true);
echo $exif['FILE']['FileName'];
//if($file != "." && $file != "..")
//{
echo $file."|";
//}
}
}
closedir($dir);
}
}

?>

Cota
04-02-2008, 02:31 PM
Glad you got it sorted. That code bit before was just a quick sniplet.