Question

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

Was it helpful?

Solution

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/');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top