linux权限move_uploaded_file

时间:2013-06-06 00:55:55

标签: file permissions copy fedora

我在linux-fedora 18上工作,函数move_uploaded_file显示警告:

错误:

[Wed Jun 05 18:41:21.731524 2013] [:error] [pid 11502] [client 127.0.0.1:40340] PHP Warning:  move_uploaded_file(/var/www/html/estampa/management/include/1.jpg): failed to open stream: Permission denied in /var/www/html/estampa/management/include/sys_content.php on line 31, referer: estampa/management/sistema/?secc=noticias&oper=mod&id=22
[Wed Jun 05 18:41:21.731547 2013] [:error] [pid 11502] [client 127.0.0.1:40340] PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpH5BLGD' to '/var/www/html/estampa/management/include/1.jpg' in /var/www/html/estampa/management/include/sys_content.php on line 31, referer: estampa/management/sistema/?secc=noticias&oper=mod&id=22

php脚本:

$archivo = $_FILES['imagen']['name'];
if($archivo != ""){
$target_path = "../../../web/images/pub/";
$target_path = dirname(__FILE__)."/";

$target_path = $target_path . basename( $_FILES['imagen']['name']); 
if($error_up = move_uploaded_file($_FILES['imagen']['tmp_name'], $target_path)) { 
$var = "El archivo ". basename( $_FILES['imagen']['name']). " ha sido subido";
} 
else{
$var = "Ha ocurrido un error, trate de nuevo!";
}
}

#ls -lrt |grep include
drwxr-xr-x. 2 apache apache 4096 May 26 15:58 include
# chmod 0777 -R include
# chown apache:apache include


httpd.conf
<Directory "/var/www/html">
    httpd.conf
    Options  -Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

和函数copy(),同样的错误

你可以帮助我吗,请帮助我。

1 个答案:

答案 0 :(得分:3)

您很可能遇到SELinux权限问题。有关详细信息,请参阅http://albertech.net/2011/03/fix-fedora-selinux-permissions-for-php-file-upload/