Jump to content

get the number of file counting


seularts

Recommended Posts

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

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
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.