Decompressing archive and setting files' owner

I'm creating an install program which needs to decompress an archive and make sure all files extracted are set to the hosting account owner which is proving harder than I thought! It's my own server and only running code which I control and so I'm using apache/mod_php rather than php as CGI/FastCGI etc although I'm considering the those options given the hassle of this.

At the moment I'm using PclZip to decompress a zip file and therefore the files extracted are owned by "apache" group/user. I then tried to use chown() and chgrp() to change the file/folder ownership/group but I get the error message "Operation not permitted" for both functions.

Surely there must be an easier way to do this? Thanks in advance for any help!
Who is Participating?
You might possibly be able to sudo a chmod / chown using exec() or system() function. This depends on your server security settings though.

wjdashwoodAuthor Commented:
Tried that and afraid that doesn't work but I think there may have been an error in the code I used original using PHP's own chown() and chgrp() functions so I'll go back and try that if there isn't an alternative.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.