(Automation) Create folders and files, and give permission inside another system with PHP

0

I'm creating an automation for a particular system and for this it is necessary that some files are created inside that system, my problem is with the permission of these files, and the permission in the folders that they will enter into the system. system. How can I give these permissions by script, I have already tried chmod () and has given this error "PHP Warning: chmod (): Operation not permitted", I tried to change the user of folders / files with chown .

code that creates folders if they do not have:

 if (!file_exists($caminho.'admin/includes/views/'.$nameMod)) {
        mkdir($caminho.'admin/includes/views/'.$nameMod, 0777, true);
        mkdir($caminho.'admin/includes/modules', 0777, true);        
        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($caminho)); 
        foreach($iterator as $item) {
            chmod($item, 0777);
        }
    }
    require_once("bo/view_adicionar.php");
    require_once("bo/view_listar.php"); 

Code that creates the files inside the folders:

$caminhoboAdicionar = $caminho.'admin/includes/views/'.$nameMod.'/';
if(**file_put_contents**($caminhoboAdicionar . 'adicionar.php', $gridDiv)){
    $msg['success'][] = 'Arquivo '.$caminhoboAdicionar .'<b>'. 'adicionar.php </b>criado com sucesso';
    chmod($caminhoboAdicionar.'adicionar.php',0777);
} else {
    $msg['error'][] = 'Erro ao criar '.$caminhoboAdicionar .'<b>'. 'adicionar.php</b>';
}

I need to have permission per scritp.

    
asked by anonymous 12.07.2018 / 18:25

0 answers