Tuesday, March 14, 2017

Laravel - Create file with specific user, group and permissions

I try to create a file by using put and give the file the permission 777.

If I create the File like this:

use File;

...

$content = "<?php echo 'test'; ?>";
$file   = app_path() . '/Http/Controllers/test.php';
File::put($file, $content);

However, the file is created with this rights:

-rw-r--r-- 1 daemon daemon 2,2K Mär 14 08:08 test.php

Also the user and group is daemon instead of root.

How can I create a file with user and group root and with permissions rwxrwxrwx ?

e.g.

-rwxrwxrwx 1 root root 2,2K Mär 14 08:08 test.php



via EdwardBlack

Advertisement