FinalFrontier Posted December 4, 2011 Share Posted December 4, 2011 Does anyone know why this isn't working? I've gone through the manual over and over for the chown string, system string, etc etc etc. I still can't get it working. chown('/home/n/Miscellaneous/uploaded files/*', n); chown('/home/n/Miscellaneous/uploaded\ files/*', n); Quote Link to comment https://forums.phpfreaks.com/topic/252444-php-chown/ Share on other sites More sharing options...
FinalFrontier Posted December 4, 2011 Author Share Posted December 4, 2011 Basically. when someone uploads a file to my private server, the file is owned by www-data. I am wanting to make it so the file is owned by me, and looking for a quick way to achieve it. I tried this, but its not working and I have no idea why: <?php $target_path = "/home/n/Miscellaneous/uploaded files/" . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { basename($_FILES['file']['name']); } system('chown n /home/n/Miscellaneous/uploaded\ files/'); ?> Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/252444-php-chown/#findComment-1294291 Share on other sites More sharing options...
dweeber Posted December 4, 2011 Share Posted December 4, 2011 Only the superuser may change the owner of a file. Your webserver is not the superuser (hopefully) Perhaps you can just chmod the file so you have permission to use it. Since the file is owned by the webserver, it can change the permissions of the file like: chmod("/somedir/somefile", 666); or whatever. As it is your server, there are many other options from the system level as well. Ref: http://php.net/manual/en/function.chown.php http://php.net/manual/en/function.chmod.php Quote Link to comment https://forums.phpfreaks.com/topic/252444-php-chown/#findComment-1294353 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.