Search code examples
apacheterminalfile-permissions

How I can change owner of files written by php


How can I change the owner of the files written by php from terminal (command line)? The files are created by upload form in apposite folder.

Many thaks


Solution

  • Use the command "chown":

    chown owner filenames
    

    To solve this problem in the future uploads, you can use the chown command:

    chown($path, $user_name);
    

    http://php.net/manual/en/function.chown.php

    There is also a chmod command, if you prefer to change permissions:

    http://www.php.net/manual/en/function.chmod.php