PHP - MKDIR用错了主人 [英] PHP - mkdir with wrong owner

查看:186
本文介绍了PHP - MKDIR用错了主人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建一个文件夹,然后复制某些文件到它的一个简单的PHP脚本。该文件夹(复制的文件)都755权限。现在的问题是,它会将用户作为Apache的。 现在,我不能删除或通过FTP更改权限。我只能'复位所有权在我的管理向导。在那里,我可以看到阿帕奇到matthdc58。

I have an simple PHP script that creates a folder and then copies certain files into it. The folder (and copied files) have all 755 permissions. The problem is, it sets the user as Apache. Now I can not delete or change permissions through FTP. I can only 'reset ownership' in my DirectAdmin. There I can see the user changes from "Apache" to "matthdc58".

我怎样才能让PHP创建matthdc58作为用户的文件夹?我试过 CHOWN() - 失败:

How can I let PHP create a folder with "matthdc58" as user? I tried chown() - failed:

Warning: chown() [function.chown]: Operation not permitted in /home/matthdc58/domains/hiddendomain.com/public_html/Home.php on line 78

Warning: chown() [function.chown]: Operation not permitted in /home/matthdc58/domains/hiddendomain.com/public_html/Home.php on line 79

Warning: chown() [function.chown]: Operation not permitted in /home/matthdc58/domains/hiddendomain.com/public_html/Home.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /home/matthdc58/domains/hiddendomain.com/public_html/Home.php:78) in /home/matthdc58/domains/hiddendomain.com/public_html/Home.php on line 90

我也试过(似乎解决别人的问题)的php_flag safe_mode设置关闭在我的.htaccess,没有prevail。

I also tried (seemed to solve others' problems) php_flag safe_mode off in my .htaccess, to no prevail.

我的整个PHP脚本:

My whole PHP script:

$dirtocreate = 'userdata/'.$_SESSION['uname'];
$oldumask = umask(0); 
mkdir($dirtocreate, 0755);
umask($oldumask);

copy('img/100x100.png', $dirtocreate.'/100x100.png');   
copy('img/64x64.png', $dirtocreate.'/64x64.png');   

//Verify correct owner
chown($dirtocreate, 'matthdc58');
chown($dirtocreate.'/100x100.png', 'matthdc58');
chown($dirtocreate.'/64x64.png', 'matthdc58');

//Verify correct permissions, just to be sure               
chmod($dirtocreate,0755);
chmod($dirtocreate.'/100x100.png',0755);        
chmod($dirtocreate.'/64x64.png',0755);


所以,我只想澄清:

  • 在我的PHP脚本设置新文件夹的所有者为阿帕奇。
  • 的PHP 脚本未能将所有者更改为matthdc58。
  • 现在,我不能编辑 通过FTP文件夹,因为主人是阿帕奇。
  • 我只能通过管理向导还原所有权与恢复者有其屋 按钮。
  • My PHP script sets the owner of the new folder to "Apache".
  • The PHP script fails to change the owner to "matthdc58".
  • Now, I can not edit the folder through FTP, since the owner is "Apache".
  • I can only restore ownership through DirectAdmin with the "Restore Ownership" button.

推荐答案

请检查您chmodded和chowned目录:/home/matthdc58/domains/hiddendomain.com/public_html/到您的用户名。 :)

Please check you have chmodded and chowned your directory: /home/matthdc58/domains/hiddendomain.com/public_html/ to your username. :)

这篇关于PHP - MKDIR用错了主人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆