Question about mkdir() on apache

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dmsweets
Forum Newbie
Posts: 3
Joined: Wed May 21, 2008 6:06 pm

Question about mkdir() on apache

Post by dmsweets »

Hi,

I'm having problems implementing a simple upload script which creates a directory and uploads images to that folder. mkdir() works but the uid and gid are owned by apache. As a result the newly created folder cannot be accessed. I have scowered the internet for documentation on this subject but to no avail.

My code is more complicated but for the purpose of testing I have created a very simple page with code as follows:

Code: Select all

 
 
<?php 
 
mkdir("/var/www/vhosts/mirandamoser.com/httpdocs/author/test", 0777);
 
?>
 
 
Has anyone else encountered this problem and if so is there a solution?

Thanks in advance
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Question about mkdir() on apache

Post by Benjamin »

Look into the chmod function.
dmsweets
Forum Newbie
Posts: 3
Joined: Wed May 21, 2008 6:06 pm

Re: Question about mkdir() on apache

Post by dmsweets »

Like I said in the above post the the uid and gid are apache. As such, nothing can be used to change the permissions including php, plesk and ftp. The only option I have with the newly created folder is to delete it.
dmsweets
Forum Newbie
Posts: 3
Joined: Wed May 21, 2008 6:06 pm

Re: Question about mkdir() on apache

Post by dmsweets »

Even the server techs don't know about this issue because they have told me to change the script but how can I make this any simpler?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Question about mkdir() on apache

Post by VladSun »

dmsweets wrote:As a result the newly created folder cannot be accessed.
What do you mean by that - which user can and which can not access it? What do you mean by "cannot be accessed" - read, write, list ...?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Question about mkdir() on apache

Post by pickle »

The 'apache' user created the directory, so it will definitely have the access rights necessary to allow you to run chmod() - the PHP function chmod(), not the shell executable. Change it so the world can access it & you should be good to go.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Question about mkdir() on apache

Post by Benjamin »

Yes, as pickle and I have already stated:
astions wrote:Look into the chmod function.
Post Reply