That is because this script isn't designed correctly to work. It would take a rewrite to work properly in an avatar field. To be specific, you can't put a img tag inside an image tag or a url. For instance that script is printing out <img src="url">, but message boards put the url inside of the image tag... so in other words what that script is creating is an image tag inside of an image tag like this:
Code:
<img src="<img src="url">">
which is the problem with this script, but even putting just the url will not work, you have to open and dump the contents of the image file.
Here is my script:
Code:
<?
$absolute_path = "/home/yoursite/public_html/avatars";
$dir = opendir($absolute_path);
while($avatar = readdir($dir)) {
if (($avatar != "..") and ($avatar != ".")) {
$avatars[] = "$avatar";
}
}
$avatars = str_replace(chr(32),"%20",$avatars);
$random = array_rand ($avatars, 1);
$randomAvatarURL=$avatars[$random];
$avatar = fopen("$absolute_path/$randomAvatarURL", "r");
while (!feof ($avatar)) {
print fread($avatar,120);
}
fclose($avatar);
?>