回答
可以讓用戶上傳文件
香港專業教育學院改變了這一帶的子文件夾,工作前檢查(通過PHP)的文件量文件夾中。
例如(您可能需要更改有點didnt運行這個....):
<?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";
?>
if($ size> = MAX_UPLOAD_AMOUNT){echo「你不能上傳更多文件」}? – michaelb958 2013-04-28 06:49:58
@ user1809599注意'> =' - 如果使用'>'代替,用戶將被限制爲201個文件而不是200個。 – michaelb958 2013-04-28 06:52:36
它不會計算子文件夾中的文件!不如預期好! – user1809599 2013-04-28 06:52:37
我發現我自己的工作解決方案!你可以嘗試下面的代碼。 200是您可以更改的文件限制!
<?php
define("MAX_UPLOAD_AMOUNT", 200);
function scan_dir($path){
$ite=new RecursiveDirectoryIterator($path);
$bytestotal=0;
$nbfiles=0;
foreach (new RecursiveIteratorIterator($ite) as $filename=>$cur) {
$nbfiles++;
$files[] = $filename;
}
$bytestotal=number_format($bytestotal);
return array('total_files'=>$nbfiles,'files'=>$files);
}
$files = scan_dir('folderlinkhere');
if ($files['total_files'] >= MAX_UPLOAD_AMOUNT)
echo "Files are more than 200. ";
else
echo "Carry out the function when less than 200";
?>
- 1. 限制特定文件夾中的文件數量
- 2. Python zipfile,文件數量奇怪的限制:「文件夾無效」
- 3. 限制文件夾
- 4. python on xp:errno 13權限被拒絕 - 限制文件夾中的文件數量?
- 5. Namenode文件數量限制
- 6. 使用camel限制文件夾中的文件數
- 7. Plone文件夾限制
- 8. 限制Hadoop中的文件夾訪問
- 9. 如何限制一個文件夾的最大文件數
- 10. 繞過程序文件文件夾的Windows權限限制
- 11. SQL Server 2012中文件和文件組的數量限制
- 12. 如何限制對codeigniter文件夾中的文件的訪問
- 13. iPhone文檔文件夾的容量是否有限制?
- 14. 限制保存在文檔文件夾中的圖像數
- 15. 在C++中限制頭文件夾
- 16. 從文件夾中檢索文件信息的限制
- 17. 在web.config中限制對文件/文件夾的訪問
- 18. htaccess限制訪問文件夾和子文件夾
- 19. log4j2 - 限制日誌文件的數量
- 20. 上傳文件的數量限制
- 21. swfupload限制上傳文件的數量
- 22. 文件夾目錄中的子文件夾數量
- 23. 忽略svn控制文件夾中的文件和文件夾?
- 24. powershell複製文件夾中的所有文件夾和文件
- 25. 限制訪問public_html內的文件夾
- 26. 限制網站的文件夾,並
- 27. 本地文件夾的大小限制?
- 28. 如何限制訪問的文件夾
- 29. 限制用戶的文件夾大小
- 30. 如何限制文件夾/子文件夾/文件只能訪問程序?
爲什麼要將文件夾中的文件數限制爲200? – michaelb958 2013-04-28 05:32:56
我允許客戶端上傳他們的文檔,所以我想限制他們可以上傳的文件的數量。另外主要原因是Inode限制 – user1809599 2013-04-28 05:34:45
除非你在Facebook的規模上構建一些東西,否則你不應該擔心inode限制。 – michaelb958 2013-04-28 05:39:09