Please use code tags, your code makes my eyes bleed
$fileName = $_FILES['imagefile']['name'];
$tmpName = $_FILES['imagefile']['tmp_name'];
$fileSize = $_FILES['imagefile']['size'];
$imtype = $_FILES['imagefile']['type'];
@list(, , $imtype, ) = getimagesize($_FILES['imagefile']['tmp_name']);
// Get image type.
if ($imtype == 3)
// cheking image type
$imageextension="png";
// to use it later in HTTP headers
elseif ($imtype == 2)
$imageextension="jpeg";
elseif ($imtype == 1)
$imageextension="gif";
else
$msg = 'Error: unknown file format';
$fp = fopen($tmpName, 'r+');
$content = fread($fp, filesize($tmpName));
//reads $fp, to end of file length
$instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img")));