napalm Posted December 14, 2008 Share Posted December 14, 2008 Hey, need some quick help... a simple, that cant be done would be nice but i would like if i could get some help on this.. The script im working with: <? $path = "./uploads/"; $dir_handle = @opendir($path) or mkdir("./uploads/); while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || $file == "index.php" ) continue; echo "$file"; } closedir($dir_handle); ?> displays files in the directory that i put.. but is there, any way that i can have it so i can set where it only displays, file types like gif, jpg, etc... so if in the directory theres html, swf, etc in the directory it does not show them... just the files i set... thanks! Link to comment https://forums.phpfreaks.com/topic/136897-deplay-only-file-types-i-set/ Share on other sites More sharing options...
.josh Posted December 14, 2008 Share Posted December 14, 2008 <?php $files = glob("*.{gif,jpg}",GLOB_BRACE); foreach ($files as $file) { echo "$file <br/>"; } ?> Link to comment https://forums.phpfreaks.com/topic/136897-deplay-only-file-types-i-set/#findComment-714985 Share on other sites More sharing options...
napalm Posted December 14, 2008 Author Share Posted December 14, 2008 Yeah, thats if i want to put the file INTO the directory.. could u help me out were i set the directory like the one i have all ready? (im slow sowy) Link to comment https://forums.phpfreaks.com/topic/136897-deplay-only-file-types-i-set/#findComment-714988 Share on other sites More sharing options...
.josh Posted December 14, 2008 Share Posted December 14, 2008 You don't know how to add something to a string? "path/to/dir/*.{gif,jpg}" Perhaps you should backup and learn the basics, because putting the cart before the horse usually isn't a good idea. Link to comment https://forums.phpfreaks.com/topic/136897-deplay-only-file-types-i-set/#findComment-715160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.