Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Mauchline, Scotland
    Thanked 1 Time in 1 Post

    php apache file ownership and creation problem

    I am trying to do a really basic rename of a file to another name in my code. However there seems to be some ownership/permissions problem that is stopping this working correctly.

    This is my (simplified) code:

    PHP Code:
    ini_set ("display_errors""1");

    $St_Num '7940';
    $Co_Code 'RDCO2';

    These are my permissions of the files I am trying to change:

    -rw-r--r-- 1 apache dev   4065 Oct 22 17:57 7940-RDCO2-3.jpg
    -rw-r--r-- 1 apache dev   4276 Oct 28 09:39 7940-RDCO2-2.jpg
    -rw-r--r-- 1 apache dev   4336 Oct 28 09:39 7940-RDCO2-1.jpg
    This code was working, and it seemed to work when apache was the *creator* of the file. However, when I changed the ownership to 'apache' it stopped working. Does PHP/Apache have a concept of knowing who the creator of a file was? Would this stop a rename() from working?

    I'm stumped with this one now - any help is appreciated.


  2. #2
    New Coder
    Join Date
    Apr 2011
    Thanked 3 Times in 3 Posts
    Who was the original owner of the file(s) in question? I'm thinking that file permissions are probably for all users to have read access only and only the file owner (apache) to have write access. You will have to change the file permissions to allow all users to write the file, from the console it would be something like chmod a+w ./<filename> .

    However that would be a bad idea since that would make it so that anyone to write to the file not just your intended user. Why do the files need to be owned by the apache user?


Tags for this Thread

Posting Permissions

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