Hi Guys,
I've been using this piece of code for years now, whenever I use rotating images within my websites. Recently, I received word that readfile() was disabled on the server I was working with for security reasons.
Here's the snippet I use:
* BEGIN CODE *
$fileList = array();
$folder = ".";
$handle = opendir($folder);
while (false !== ($file = readdir($handle) ) )
{
if ( substr($file, -4) == ".gif" || substr($file, -4) == ".jpg" )
{
$fileList[count($fileList)] = $file;
}
}
closedir($handle);
$randNum = rand( 0, (sizeOf($fileList) -1) );
if ( substr($fileList[$randNum], -4) == ".gif" )
{
header ("Content-type: image/gif");
}
elseif ( substr($fileList[$randNum], -4) == ".jpg" )
{
header ("Content-type: image/jpeg");
}
readfile($fileList[$randNum]);
* END OF CODE *
any suggestions or possible alternatives to use instead of readfile()?
many thanks in advance.