If chown is filled with a variable ( chown ("myfile", $uid) the uid will be looked up through pwget_uid.
So if you need to set a non existing uid use inval($uid).(PHP 4, PHP 5, PHP 7, PHP 8)
chown — Cambia el propietario del fichero
Cambia el propietario del fichero
filename a user.
Solo el superusuario (root) puede cambiar arbitrariamente
el propietario de un fichero.
filenameRuta hacia el fichero.
userUn nombre o un número de usuario.
Ejemplo #1 Ejemplo con chown()
<?php
// Nombre del fichero y nombre de usuario a utilizar
$file_name= "foo.php";
$path = "/home/sites/php.net/public_html/sandbox/" . $file_name ;
$user_name = "root";
// Define el usuario
chown($path, $user_name);
// Verificación del resultado
$stat = stat($path);
print_r(posix_getpwuid($stat['uid']));
?>Resultado del ejemplo anterior es similar a:
Array
(
[name] => root
[passwd] => x
[uid] => 0
[gid] => 0
[gecos] => root
[dir] => /root
[shell] => /bin/bash
)
Nota: Esta función no funciona con los archivos remotos, ya que el archivo examinado debe ser accesible en el sistema de archivos del servidor.
Nota: En Windows, esta función falla silenciosamente cuando se aplica sobre un fichero ordinario.
If chown is filled with a variable ( chown ("myfile", $uid) the uid will be looked up through pwget_uid.
So if you need to set a non existing uid use inval($uid).It may be worth making explicitly clear that, while the shell's `chown` command allows both user and group to be set in one system call like this `chown username:groupname filename`, PHP's version unfortunately does not:
<?php
// This will not work.
chown($filename, 'username:groupname');
// You have to use two separate calls.
chown($filename, 'username');
chgrp($filename, 'groupname');
?>