Linux - PHP mkdir creates directory, but no write permission? -


i run php file command line following code inside:

if(!is_dir($path)) {     mkdir($path, 0666, true); } 

no error thrown code , folder created expected.

if afterwards:

file_put_contents("some data", $path . "filename.txt"); 

i "failed open stream: permission denied" exception.

even if

chmod($path, 0777); 

after mkdir inside php code, error.

if manually create directory , set 777 linux commands, everythig works fine. why that?

you can set permission while creating directory

mkdir($path, 0777, true)

also need change syntax of file_put_contents

file_put_contents($path . "/filename.txt", "some data");


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -