Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2003
    Location
    USA, FL
    Posts
    251

    PHP - File Operations

    I know how to create a file in PHP but how do you create that file so that it is not "nobody" and is under the name of the website?

    Syphic

  2. #2
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    When you create a file from PHP, it is automatically owned by the server process (which is usually nobody). If you want to change the owner of the file later, you have to login as root and then run the command chown on the file.

    All files created by processes running under a webserver are automatically owned by the webserver user. You can use suexec (which allows PHP to run as a different user) to create files that belong to a different user.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  3. #3
    You can also change the server idnetity so it is no longer nobody (for security reasons, nobody is a default low privilege user) or change the groupt nobody belongs toĻ.

  4. #4
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Originally posted by fyrestrtr
    When you create a file from PHP, it is automatically owned by the server process (which is usually nobody). If you want to change the owner of the file later, you have to login as root and then run the command chown on the file.

    All files created by processes running under a webserver are automatically owned by the webserver user. You can use suexec (which allows PHP to run as a different user) to create files that belong to a different user.
    It will not work..

    Unless you chmod the file during the process, you wont be able to change permissions even from an ftp manager..

    It happened to me once, i create php files on the fly, and when later on tried to access it, it will not allow me to even change the CHMOD, it actually lets me do it but when refreshing it goes back to the same CHMOD setting. It also happenes when uploading image files!

    I then thought I would have to CHMOD when creating the files..

    peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  5. #5
    Join Date
    Jan 2003
    Location
    USA, FL
    Posts
    251
    what about ftp - php functions? is there anyway there to create a file? or copy a file and paste information into it?

  6. #6
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    Azizny:

    Your problem is different. The user that you FTP in as should be able to CHMOD files created by PHP scripts -- since this is the default setup on most hosting environments.

    The other part -- about uploading image files -- there is a setting in Apache that sets the default permission for files uploaded, which is what is happening in your case.

    Syphic:

    You can create a file by executing 'touch nameofile'. Even when you FTP, you can't create the file on the remote machine, you can only copy/move files. You'd have to create it first locally, then FTP it to the remote server. Maybe if you described your problem, people can suggest an alternate solution.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  7. #7
    Join Date
    Mar 2004
    Posts
    1,468
    I had that problem once.
    I had to copy the contents of each file, create a new directory, new files, and paste all of the contents in each file individually. It took a looonnng time.

    Wont just setting chmoding it to 755 or whatever when you create the file avoid this?

  8. #8
    Join Date
    Jan 2003
    Location
    USA, FL
    Posts
    251
    not really jasong... Also, I am not uploading anything fyrestrtr. I am trying to create files right on the server. Have tried it that way jasong and havent had any luck. Right now php chmod functions is disabled so that is not an option. I am not on a root account so that is not an option. What other information do you need to know? I am just trying to create files. If i can create files off another file by coping I would not mind doing it that way. I could build a function which copied the file, renamed it, and then clearned. Havent had much luck but will try again.

    Syphic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •