paulferree Posted February 23, 2008 Share Posted February 23, 2008 I was wondering if there was a function that would help me create a page that will look at a folder (an image folder, that I predefine) and return all the file names in that folder. Is there a function already made for this, if there isn't how would I go about creating one? I just want to upload my images to a folder and have the php extract them all and display them on the page. Any ideas? Thanks, Paul Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 23, 2008 Share Posted February 23, 2008 http://php.net/readdir if($handle = opendir('dir/')) { while(false !== ($file = readdir($handle))) { echo "$file \n"; } closedir($handle); } Quote Link to comment Share on other sites More sharing options...
paulferree Posted February 23, 2008 Author Share Posted February 23, 2008 Great!! I should've checked the function reference manual first, I apologize...but this is better than the example given on the PHP site...thanks a lot Chris. Paul Quote Link to comment Share on other sites More sharing options...
paulferree Posted February 23, 2008 Author Share Posted February 23, 2008 I was looking at this one BTW: [pre]<?php $dir = "/tmp"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } sort($files); print_r($files); rsort($files); print_r($files); ?> [/pre] Quote Link to comment Share on other sites More sharing options...
Demonic Posted February 23, 2008 Share Posted February 23, 2008 Or you could use "glob" http://php.net/glob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.