错误“open_basedir限制生效”

时间:2012-09-01 18:58:47

标签: php

我正在建立一个有图片上传的网站。

这是负责图片上传的部分:

$ip=rand();
$filename1 = "/public_html/friendscave/temporary/".$ip;
$filename2 = "/public_html/friendscave/temporary/".rand();
$filename3 = "/public_html/friendscave/temporary/".rand();
$filename4 = "/public_html/friendscave/temporary/".rand();
copy($pictures1, $filename1);
copy($pictures2, $filename2);
copy($pictures3, $filename3);
copy($pictures4, $filename4);
$fp1 = fopen($filename1, 'r');
$contents1 = fread($fp1, filesize($filename1)); 
$fp2 = fopen($filename2, "r");
$fp3 = fopen($filename3, "r");
$fp4 = fopen($filename4, "r");
$contents2 = fread($fp2, filesize($filename2)); 
$contents3 = fread($fp3, filesize($filename3)); 
$contents4 = fread($fp4, filesize($filename4));
fclose($fp1); 
fclose($fp2); 
fclose($fp3); 
fclose($fp4);  
$encoded1 = chunk_split(base64_encode($contents1));  
$encoded2 = chunk_split(base64_encode($contents2));  
$encoded3 = chunk_split(base64_encode($contents3));  
$encoded4 = chunk_split(base64_encode($contents4));  

这是我得到的错误

Warning: copy() [function.copy]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /PostAD.php on line 130

我不明白这个错误。 有人能帮帮我吗?

1 个答案:

答案 0 :(得分:3)

您只能打开/home/usr/lib/php/tmp下的文件,但是您尝试在/public_html下打开文件。

你确定你真正意味着根目录中的目录,而不是用户的主目录(/home/someuser/public_html)吗?

相关问题