如何在php中创建一个文件夹并限制该文件夹中的上传

问题描述:

i want so set a limit on a folder which is being created by the user:

according to script below:

$root = "/users/homedir/";
if (!is_dir($root))
{
    @mkdir("users/homedir/", 0777);

The folder homedir should contain max 20 Mb of storage. If this is reached, the user can not upload into that folder anymore. How can i set those 20 Mb limit to that folder when it is created?

我想对用户创建的文件夹设置限制: p> \ n

根据以下脚本: p>

  $ root =“/ users / homedir /”; 
if(!is_dir($ root))
 {
 @  mkdir(“users / homedir /”,0777); 
  code>  pre> 
 
 

文件夹 homedir strong>应包含最多20 Mb的存储空间。 如果达到此目的,则用户无法再上传到该文件夹​​。 如何在创建时将该20 Mb限制设置为该文件夹? p> div>

You can't set a limit at the time of creation, but you can check the directory size along with the size of the file being uploaded, and limit based on those values.