Permission Denied When Using PHP mkdir Function
When using PHP's mkdir function to create a directory, you may encounter a "Permission denied" error. This error indicates that the PHP process, typically running under Apache, does not have the necessary permissions to create the directory.
Solution: Correct File Ownership and Permissions
To resolve this issue, adjust the file ownership and permissions on the parent directory where you intend to create the new subdirectory.
In Ubuntu, follow these steps:
sudo chown -R www-data:www-data /path/to/webserver/www
sudo chmod -R g+rw /path/to/webserver/www
After making these changes, the PHP mkdir function should operate correctly without prompting permission errors.
The above is the detailed content of Why Does PHP\'s mkdir Function Return \'Permission Denied\' and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!