0

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

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

$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

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

4

1 回答 1

3

您只能打开/home,/usr/lib/php和下的文件/tmp,但您正试图打开 . 下的文件/public_html

您确定您的意思是直接在根目录中的目录,而不是在用户的主目录 ( /home/someuser/public_html) 中吗?

于 2012-09-01T19:16:59.897 回答