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!? Quote Link to comment 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 } ?> 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.