mendoz Posted January 12, 2007 Share Posted January 12, 2007 Listen up freaks!I have a folder with a lot of pictures, only jpeg pictures.Now I need to get all those pictures and print them.Getting them into an array would be nice.Let's see who got what it takes :-*Thanks,Dror Link to comment https://forums.phpfreaks.com/topic/33894-get-all-the-images-in-a-folder/ Share on other sites More sharing options...
HuggieBear Posted January 12, 2007 Share Posted January 12, 2007 [quote author=mendoz link=topic=122099.msg503115#msg503115 date=1168612972]Let's see who got what it takes :-*[/quote]How about you?!?!?Dror,I've helped you out before and I find the task you're requesting now very easy. Have you attempted it yourself yet? If not then perhaps give it a go and then post what you came up with here when/if you get a problem.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/33894-get-all-the-images-in-a-folder/#findComment-159100 Share on other sites More sharing options...
obsidian Posted January 12, 2007 Share Posted January 12, 2007 If you know for sure they're the only ones in the folder, all you've got to do is loop through the directory with readdir(). If you need to check the extensions, you can easily add that to the following code:[code]<?php//Open images directory$images = "path/To/Files";$dir = opendir($images);$files = array();while (($file = readdir($dir)) !== false) { // Account for directory structure references if ($file != '.' && $file != '..') { $files[] = $file; }}closedir($dir);// Now $files holds the name of all your files?>[/code]A simple google search would have come up with similar code. Link to comment https://forums.phpfreaks.com/topic/33894-get-all-the-images-in-a-folder/#findComment-159102 Share on other sites More sharing options...
mendoz Posted January 12, 2007 Author Share Posted January 12, 2007 Thanks!You're right Huggy, but I just came back from boot camp (don't ask) and my client is pissing me off.Anyway I'll be releasing this product management system to the public so it's for everyone. Link to comment https://forums.phpfreaks.com/topic/33894-get-all-the-images-in-a-folder/#findComment-159111 Share on other sites More sharing options...
Recommended Posts