searls03 Posted October 14, 2012 Share Posted October 14, 2012 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. 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 $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 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 Link to comment https://forums.phpfreaks.com/topic/269441-multiple-file-upload/#findComment-1385085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.