seularts Posted June 8, 2008 Share Posted June 8, 2008 i get the number of files with this.. <?php $dirname = "./pics/"; $images = scandir($dirname); $ignore = Array(".", ".."); foreach($images as $curimg){ if(!in_array($curimg, $ignore)) { echo " <a href='./pics/$curimg' rel='lightbox' id='imgi' title='Prezentare Sablon'> <img src='./pics/$curimg' id='img' height='150px' /></a>\n"; }; } ?> the thing is that i want to tell the script that when it reaches 6 files, for example, in the folder, to forbin any further uploads! how can i give the if statement!? Link to comment https://forums.phpfreaks.com/topic/109267-get-the-number-of-file-counting/ Share on other sites More sharing options...
GingerRobot Posted June 8, 2008 Share Posted June 8, 2008 Just increment a number in your foreach loop: <?php $dirname = "./pics/"; $images = scandir($dirname); $ignore = Array(".", ".."); $total = 0; foreach($images as $curimg){ if(!in_array($curimg, $ignore)) { echo "\n<a href='./pics/$curimg' rel='lightbox' id='imgi' title='Prezentare Sablon'> <img src='./pics/$curimg' id='img' height='150px' />[/url]\n"; $total++; } } if($total > 5){ //upload not allowed } ?> Link to comment https://forums.phpfreaks.com/topic/109267-get-the-number-of-file-counting/#findComment-560458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.