Jump to content

chmod, chgrp and chown doesnt work from php


wmguk

Recommended Posts

Hi Guys,

 

I'm running a script however I get this error:

Notice: Use of undefined constant ftpiwphoto - assumed 'ftpiwphoto' in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 15

Warning: chown() [function.chown]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 15

Notice: Use of undefined constant psacln - assumed 'psacln' in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 16

Warning: chgrp() [function.chgrp]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 16

 

this is the script

if (is_dir($thisdir ."/$login") )
{
}
else
{
if(mkdir($thisdir ."/$login" , 0777, true)){
if ($user = 'kmaunton'){
chown($thisdir ."/$login" , ftpiwphoto);
chgrp($thisdir ."/$login" , psacln);
} else { }
}

else
{
   echo "<p class='footer'>Failed to create directory... <br> Contact <a href='mailto:drew@wicked-websites.co.uk'>Wicked Websites</a></p>";
} 

 

any thoughts as to why this wont work?

Link to comment
Share on other sites

Ok, I've tidied the code up slightly but I still get this error:

 

Warning: chown() [function.chown]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 16

Warning: chgrp() [function.chgrp]: Operation not permitted in /var/www/vhosts/iwphoto.co.uk/httpsdocs/photographer/createadmin/create.php on line 17

Link to comment
Share on other sites

I should let the experts talk on this, but chown() can only be used by the superuser. Stated in the manual:

 

Only the superuser may change the owner of a file. 

 

The Apache user, shouldn't be a superuser so I guess that's why you are getting errors.

Link to comment
Share on other sites

ahh, ok, :( the problem is there are 3 different people using this script, 2 people use windows explorer for ftp access, and one uses ftp software.

 

when the user is apache the 2 people using windows explorer can connect and upload etc.... however the other chap cant, and if i set the user as ftpiwphoto then he can use the software but they cant use explorer...

 

the idea was, if he creates the account then its chmoded to ftpiwphoto, however if its the other two then its just apache...

 

I'll have to try something else, I looked at a drag and drop php ftp program but just couldnt get it to work, and this seemed to work well to start with, but now I have this problem.

 

the issue is it needs to be a drag and drop system as there could be 800 images per upload so just having a browse style button wont be practical....

 

 

Link to comment
Share on other sites

  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.