I have a folder name /clientupload/ in my host. I want to limit the number of files in clientupload folder and its sub-folder to total 200.
I dont have any idea how to do that!
I have a folder name /clientupload/ in my host. I want to limit the number of files in clientupload folder and its sub-folder to total 200.
I dont have any idea how to do that!
you can check (via php) amount of files in folder before letting the user upload the file
ive changes this to work with sub-folder.
for example (you might need to change a bit didnt run this....) :
<?php
define("MAX_UPLOAD_AMOUNT", 200);
//switch to your dir name
$dirName = "/Temp/";
//will count number of files
$totalFileAmount = countFiles($dirName);
function countFiles($dirName){
$fileAmount = 0;
//open dir
$dir = dir($dirName);
//go over the dir
while ($file = $dir->Read()){
//check there are no .. and . in the list
if (!(($file == "..") || ($file == "."))){
//check if this is a dir
if (Is_Dir($dirName . '/' . $file)){
//yes its a dir, check for amount of files in it
$fileAmount += countFiles($dirName . '/' . $file);
}
else{
//its not a dir, not a .. and not a . so it must be a file, update counter
$fileAmount++;
}
}
}
return $fileAmount;
}
//check if user can upload more files
if ($totalFileAmount >= MAX_UPLOAD_AMOUNT)
echo "You have reached the upload amount limit, no more uploaded";
else
echo "let the user upload the files, total number of files is $totalFileAmount";
?>