Utilisation
img src="votrepage.php" alt="mon image"
Code :
<?
$dir = './' ; // indiquez ici votre r?pertoire.
$array_file = array() ;
if ( is_dir ( $dir ) )
{
if ( $handle = opendir ( $dir ) )
{
while ( ( $file = readdir ( $handle ) ) !== false )
{
if ( $file != '.' && $file != '..' && getimagesize ( $file ) )
{
$array_file[] = $file ;
}
}
closedir ( $handle ) ;
}
}
shuffle ( $array_file ) ;
$type = getimagesize ( $dir . $array_file[0] ) ;
$handle = fopen ( $dir . $array_file[0] , 'rb' ) ;
header ( 'Cache-Control: no-cache, must-revalidate' ) ;
header ( 'Pragma: no-cache' ) ;
header ( 'Content-type: ' . $type['mime'] ) ;
fpassthru ( $handle ) ;
exit() ;
?>