如何在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?

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.