Aache 2.0 with subdomains & PHP- directory creation permission problems

I am running Apache 2.0 with subdomains. My application is PHP-based. When a user (anonymouse) uploads a file, the file is placed in a new directory with an owner of "apache". The image processing that is then supposed to occur under GD fails- until I change the directory owner to "site6". I am also using the Ensim Pro control panel under Fedora Core 2. Any way to have those directories set with an owner of site6 upon creation? Does PHP have the capability to set new file/directory permissions?
Who is Participating?
Yep, chmod() - http://us2.php.net/manual/en/function.chmod.php

Try it, but I'm guessing you'll might have problems.  If it doesn't work, I think the quickest solution would be to make the users site1/site2/site3/etc. members of the apache group.  Then, you'll probably be able to do a chown() on the file to change it's ownership to the current user - http://us2.php.net/manual/en/function.chown.php.  If you have problems getting chown() to work (i.e. it still says you don't have permission) then you might have to change the umask for your apache user.  The umask handles the default permissions when files are created.  I'm not sure *exactly* where you'd use it, but php also has a umask() function - http://us3.php.net/umask.  I would guess you'd put it at the top of the page where the files are actually handled after they're uploaded.  I'm thinking you'd probably do something like this:


... handle file upload

foreach($uploaded_files as $file) {
    chown($file, "my_user");
    // if you want only this user to have access this file:
    chmod($file, 0700);

Anyway, I hope that at least gives you some more insight into your problem.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: dougday

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer
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.