View Full Version : PHP script to read file names into Flash
andrthad
January 20th, 2003, 11:41 AM
Hi,
I was wondering if anybody could give me some direction on how to use PHP to read files names located in a server folder into Flash MX. Once in Flash MX I would like to read these file names into an array. A link, thread, tute, anything would be helpful.
eyezberg
January 20th, 2003, 05:37 PM
<?php
if ($dir = opendir("./")) {
while (($file = readdir($dir)) !== false) {
$cont++;
if ($file == "." || $file == "..") { } else {
$string.="file$cont=$file&";
}
}
closedir($dir);
}
$string.="status=OK";
print($string);
?>
save as listfiles.php , and you're done..
andrthad
January 20th, 2003, 06:32 PM
Hi eyezberg,
Thank you for taking the time to answer this thread. Forgive my simple questions.
Just to further explain request. I have a website in a root folder. I have a music subfolder with a list of mp3s. I want to read this list of mp3 file names into an array (called songList) located in flash.
From the code you give below can I do something like this to get it into my array in Flash:
//frame action
loadVariablesNum("listfiles.php", 0);
songList = string;
I am sure I am oversimplifying.
eyezberg
January 21st, 2003, 03:10 AM
Put the php file into your mp3 folder, then call it directly from your browser to see the output (www.yoursite.com/mp3folder/listfiles.php)
and work from there.
Basically, you get file1=song.mp3&file2=anothersong.mp3&...&status=OK
so you want to check on status variable to see if your load is finished, then you could loop thru the string and split it at &,
so you get an array...
All depends on how you set up your swf, and what info you want to display..alos have (somewhere) a php reading all files, sizes, extensions etc..
let me know
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.