PHP random image from dir help

Well , I did my first PHP script today and I came up with a script that will grab a random image from the directory I specified and then display it along with some css and html stuff.
My problem is that it keeps echoing “”.
As if it was displaying the index of the directory which I can’t figure out how to use and image as the index either.
My code is as follows:

[php]<?php
$dir = getcwd();
$dir = str_replace("\", “/”, $dir);
$dir = $dir . “/images/”;

if( $checkDir = opendir($dir) )
{
$cFile = 0;
// check all files in $dir, add to array listFile
while( $file = readdir($checkDir) )
{
if($file != “.” && $file != “…”)
{
if( !is_dir($dir . “/” . $file) )
{
$listFile[$cFile] = $file;
$cFile++;
}
}
}
}
$num = rand(0, count($listFile) );
echo " body { background-image:url(‘http://www.hdwallpapers.in/walls/abstract_color_background_picture_8016-wide.jpg’); } #frame1 { border:10px solid gray; } ";
echo “”;
echo “<img src='http://www.digitalcraftingonline.com/rate-me/images/”;
echo $listFile[$num];
echo “'height=300 id=‘frame1’ onLoad=autoResize(‘iframe1’);>
”;
echo “

”;
?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service