I am trying to write a function that will call PHP umask before I make directory.
As I read that is the way to grant all permissions on the specific folder and files that will be saved there.
I tried on example below but still didn't fix permissions.
public function getPermissions()
{
$oldmask = umask(0);
umask($oldmask);
}
And here I call service that handles this function before I make new directory:
// get directory path
$rootDir = $this->container->get('kernel')->getRootDir();
$dir = $rootDir . '/../web/uploads/Statements/';
$this->get('file_service')->getPermissions();
// make new directory
if(!is_dir($dir)) {
mkdir($dir, 0777, true) || chmod($dir, 0777);
}