The chown() function changes the file owner. Set a new owner for any file. This function won’t work for remote files.
chown($file_path, $user );
file_path − Set the path of file or directory to be checked. Required.
user − Set the new owner name or id.
The chown() method returns.
The following is an example that set new owner for file “demo.txt”.
<?php // set new owner $file_path = "demo.php"; $user = "jack"; chown($file_path, $user); ?>
Let us see another example, wherein a new user is set for file “new.txt”.
<?php // set new owner chown("new.txt","amit"); ?>