PHP Copy() Giving Wrong File Ownership

Discussion in 'PHP' started by LazyD, Sep 12, 2007.

  1. #1
    Im attempting to you use Copy() to copy a folder and its files to another folder on the server. The problem is that the Userid is 99, which is PHP's file ownership number, how can I copy the files and folder with my user ownership number/name.
     
    LazyD, Sep 12, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You cannot copy folders with copy() alone. But there are some samples in the user comments on the copy() manual page, on how to copy folders.
     
    nico_swd, Sep 12, 2007 IP
  3. LazyD

    LazyD Peon

    Messages:
    425
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nico, im using a function on that page to recursively move a folder and all of its files. Its moving them correctly but using PHP's userid and groupid which is not allowing me to move/delete them via FTP.
     
    LazyD, Sep 12, 2007 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    LazyD: just to be absolutely clear, it's not PHP's user ID, it's 'nobody' (which is the user that runs Apache).

    You need to run chown and chgrp on the files after copying them... there's really no 'automatic' way of doing it I'm afraid.
     
    TwistMyArm, Sep 12, 2007 IP
  5. DKameleon

    DKameleon Member

    Messages:
    29
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    38
    #5
    If chown / chgrp will not work,
    this can be solved by assigning permissions to files/directories that allows access for other groups.
    Just set chmod for every file to 666 or 777 after copying.
     
    DKameleon, Sep 12, 2007 IP