Permission denied on mkdir()

后端 未结 2 1885
小蘑菇
小蘑菇 2021-01-12 05:38

I\'m getting the following error when trying to call mkdir() on a server...

Warning: mkdir() [function.mkdir]: Permission denied in /home/server/p

相关标签:
2条回答
  • 2021-01-12 06:12

    Make sure the parent folder is writable to the process that the web server runs as.

    Edit: Oops, premature reply. Does your host give you a GUI file browser thingy?

    0 讨论(0)
  • 2021-01-12 06:17

    is_writable() is probably the function you're looking for.

    http://cz.php.net/manual/en/function.is-writable.php says:

    Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.

    Also, the directly next line is relevant here:

    Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody').

    In other words, check if your directory is writable by the user id of the web server - this may be a different user id than yours! Set the appropriate permissions - e.g. set the usergroup of the folder to that of the server's user, and grant read, write, and execute to group. (chgrp somegroup uploads; chmod g+r uploads; chmod g+w uploads; chmod g+x uploads)

    0 讨论(0)
提交回复
热议问题