回答
可以讓用戶上傳文件
香港專業教育學院改變了這一帶的子文件夾,工作前檢查(通過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 on xp:errno 13權限被拒絕 - 限制文件夾中的文件數量?
- 3. 使用camel限制文件夾中的文件數
- 4. Plone文件夾限制
- 5. 限制Hadoop中的文件夾訪問
- 6. 如何限制一個文件夾的最大文件數
- 7. 繞過程序文件文件夾的Windows權限限制
- 8. 磁盤IO性能限制基於文件夾/文件的數量
- 9. iPhone文檔文件夾的容量是否有限制?
- 10. 限制保存在文檔文件夾中的圖像數
- 11. 在C++中限制頭文件夾
- 12. 在web.config中限制對文件/文件夾的訪問
- 13. 從文件夾中檢索文件信息的限制
- 14. htaccess限制訪問文件夾和子文件夾
- 15. 忽略svn控制文件夾中的文件和文件夾?
- 16. powershell複製文件夾中的所有文件夾和文件
- 17. 限制網站的文件夾,並
- 18. 限制用戶的文件夾大小
- 19. 如何限制訪問的文件夾
- 20. 如何限制文件夾/子文件夾/文件只能訪問程序?
- 21. 文件夾權限?
- 22. 文件夾權限
- 23. 文件夾權限
- 24. 文件夾權限
- 25. 限制MATLAB調用與運行文件相同的文件夾中的函數
- 26. 計算複雜文件夾結構中每個文件夾的文件數量?
- 27. ubuntu中父文件夾和子文件夾的權限
- 28. C#將文件複製到具有權限的文件夾
- 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