nfx Posted January 16, 2009 Share Posted January 16, 2009 Hi, Right now I have some code that lists and links the last 15 flash files added to a directory, and I'm trying to get it to list their dimensions as well. Everything is fine except for the dimensions part. It lists the lastest 15 files and links them properly. But with the addition of showing the dimensions, it lists the first two files and then I get an error saying "Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 42357986 bytes)". Is there any way to avoid using so much memory? Is there a way to get it to find the dimensions only when the link is clicked? Here's what I have: <?PHP // BEGIN reading and sorting directory $dirpath = getcwd() . "/a/"; $dir = opendir($dirpath); $files = array(); while ($file = readdir($dir)) { $localpath = $dirpath.$file; if (is_file($localpath)) { $key = filemtime($localpath).md5($file); //sort key is date $files[$key] = $file; } } krsort($files); //sort so latest date is first // END reading and sorting //BEGIN listing $limitthis = 0; foreach ($files as $file) { if (strpos($file, '.swf',1)||strpos($file, '.dcr',1) ) { if($limitthis < 15){ // Get only the last 15 files added $fileext = $file; $ext = strrchr($fileext, '.'); if($ext !== false) { $fileext = substr($fileext, 0, -strlen($ext)); // Strip the extension off } $details = getimagesize("a/$file"); // ***** HERE'S THE PROBLEM ***** echo "{$details[0]}x{$details[1]} "; echo "<a href=\"#\" onClick=\"selectgame('$file','$fileext')\">$file</a><br>"; // Link to a javascript function $limitthis++; } else break; } } // END foreach //END listing ?> Link to comment https://forums.phpfreaks.com/topic/141031-solved-getimagesize-for-multiple-swfs/ Share on other sites More sharing options...
nfx Posted January 16, 2009 Author Share Posted January 16, 2009 Is there not a more efficient way to do this? Link to comment https://forums.phpfreaks.com/topic/141031-solved-getimagesize-for-multiple-swfs/#findComment-738453 Share on other sites More sharing options...
nfx Posted January 16, 2009 Author Share Posted January 16, 2009 Well it turns out it was having problems because it got to a flash file that was over 20mb big. I threw in an if statement with filesize() < 12000000 and that makes the rest of it work just fine. Shame that I can't find out the dimensions of the big files though. Link to comment https://forums.phpfreaks.com/topic/141031-solved-getimagesize-for-multiple-swfs/#findComment-738478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.