A forum that I post on only allows .jpg, .png and .gif images to be loaded from an external URL. I want to get around this and have a dynamic avatar chosen randomly from a directory on my server but I'm having trouble getting it to work (possibly due to extra checks being carried out on the external site, or an error in my code).
So far I've created a folder named "avatar.jpg" on my server and the code in my index.php file within that folder is as follows:-
<?php
$arr=array();
for($i=1;$i<6;$i++){
$arr[$i]=$i.".jpg";
}
$random=rand(1,6);
echo $arr[$random];
?>
I have 6 images in the avatar.jpg folder, named 1.jpg, 2.jpg etc.
When I run mydomain.com/avatar.jpg it correctly displays a random image source, eg. 5.jpg, but when I enter this URL as my avatar URL on the forum it fails to load and Firebug reports "Failed to load given URL".
Am I missing something from my code to make this work as hoped?