Pregunta

The Php code creates nested directories and sets them permissions:

$pathToFile = 'public/loaded/' . $category . date('/Y/m/d/H/i/');
        $pathToFile = str_replace('//', '/', $pathToFile);
        if(!file_exists($pathToFile)){
            mkdir($pathToFile, 0775, true);
        }

        chmod( $pathToFile, 0775);

Result of this action is :

Message: mkdir(): Permission denied Message: chmod(): No such file or directory

In terminal Ubuntu i tried change permission on root directory /public:

chmod -R ug+rw /public

But this command helped, so, what permission must be on folder where loads all users images and documents?

chmod 777 -R public

¿Fue útil?

Solución

mkdir() requires a full path, not a relative one.

Try this instead:

$pathToFile = $_SERVER['DOCUMENT_ROOT'] . '/public/loaded/' . $category . date('/Y/m/d/H/i/');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top