婆罗门
精华
|
战斗力 鹅
|
回帖 0
注册时间 2005-6-2
|
楼主 |
发表于 2011-2-3 01:44
|
显示全部楼层
谢谢各位大大
我现在成功了!
代码如下,以下代码做成face.php
<?php
$okext = array("jpg", "jpeg", "gif", "png");
$dir = 'images';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
$ext = pathinfo($file);
$ext = $ext["extension"];
if ($file != "." && $file != ".." && in_array($ext, $okext)) {
$imfiles[] = $file;
}
}
closedir($handle);
}
$id = rand(0, count($imfiles)-1);
header('Content-Disposition: inline;');
readfile($dir."/".trim($imfiles[$id]));
?>
目录是这样的
空间根目录下建立一个face文件夹
face文件夹之下建立一个images文件夹
face.php放在face文件夹里
头像(我全部统一改成jpg格式 120*120)放在images文件夹
在论坛里
支持php结尾的论坛用http://我的域名/face/face.php
不支持php结尾的论坛用http://我的域名/face/face.php?.jpg
请问这种科学吗!! |
|