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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.