searls03 Posted October 14, 2012 Share Posted October 14, 2012 (edited) is there a way to use php, or some other coding, to make all pictures in a certain folder display as: <a href="directory here" title="title" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a> for example. so if there were two pictures, it would display them as: <a href="directory here" target="_blank"><img src="source here" width="570" height="270" alt="Slide 2"></a> <a href="directory2 here" target="_blank"><img src="source2 here" width="570" height="270" alt="Slide 3"></a> etc. I do not want to use a database with these please. Edited October 14, 2012 by searls03 Quote Link to comment https://forums.phpfreaks.com/topic/269441-multiple-file-upload/ Share on other sites More sharing options...
cmb Posted October 14, 2012 Share Posted October 14, 2012 (edited) $dir = "path/to/directory/*"; foreach(glob($dir) as $file){ if (filetype($file)== 'file'){//only displays files no subdirectorys echo "<a href='http://www.google.com' target='_blank'><img src='".$file."' width='570' height='270 alt='slide' /></a><br />"; }//close file check }//close foreach Edited October 14, 2012 by cmb Quote Link to comment https://forums.phpfreaks.com/topic/269441-multiple-file-upload/#findComment-1385082 Share on other sites More sharing options...
jcbones Posted October 14, 2012 Share Posted October 14, 2012 If you want to make sure it returns images only, use: (using cmb's code). $dir = "path/to/directory/*.[pPjJgG][nNpPiI][gGfF]"; //case insensitive, gets only jpg, JPG, png, PNG, gif, GIF files. foreach(glob($dir) as $file){ //only displays files no subdirectorys echo "<a href='http://www.google.com' target='_blank'><img src='".$file."' width='570' height='270 alt='slide' /></a><br />"; }//close file check }//close foreach Quote Link to comment https://forums.phpfreaks.com/topic/269441-multiple-file-upload/#findComment-1385085 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.