I know this is an old thread, but it needs a better answer. You shouldn’t need to set the permissions to 777, that is a security problem as it gives read and write access to the world. It may be that your apache user does not have read/write permissions on the directory.
Here’s what you do in Ubuntu
Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user
chown -R www-data:www-data /path/to/webserver/www
Next enabled all members of the www-data group to read and write files
chmod -R g+rw /path/to/webserver/www
The php mkdir() function should now work without returning errors
我知道这是一个古老的方法了,但它需要一个更好的答案。你不应该将权限设置为777,这不安全, 因为它给所有访问者读和写的权限。出现问题的原因可能是,你的apache用户不具有读/写权限的目录。
下面是在Ubuntu下你应该怎么做:
确保所有文件属于Apache组和用户。Ubuntu里面,指的是www - data组和用户
chown -R www-data:www-data /path/to/webserver/www
接下来赋予www-data组的所有成员以读和写的权限。
chmod -R g+rw /path/to/webserver/www
现在mkdir()应该可以正常工作了。