Greetings,
I've written a custom module for Postnuke for a College here in Dublin. The module allows lecturers to upload notes for a given subject, which in turn allows the students of that subject to download the notes. For the most part there are no problems. The only problem is when a lecturer uploads a HTMl file.
When a student tries to download the HTML file, it is three times the size of the original. So that when the HTML file is opened in a browser it's like seeing the same web page three times, one above the other.
I can't understand why this is happening. I would appriciate it if someone could point me in the right direction.
Sample Code
function downloadFile($strFileType,$strFileName,$file_location)
{
$ContentType = "application/octet-stream";
if ($strFileType == ".asf")
$ContentType = "video/x-ms-asf";
if ($strFileType == ".avi")
$ContentType = "video/avi";
if ($strFileType == ".doc")
$ContentType = "application/msword";
if ($strFileType == ".zip")
$ContentType = "application/zip";
if ($strFileType == ".xls")
$ContentType = "application/vnd.ms-excel";
if ($strFileType == ".gif")
$ContentType = "image/gif";
if ($strFileType == ".jpg" || $strFileType == "jpeg")
$ContentType = "image/jpeg";
if ($strFileType == ".wav")
$ContentType = "audio/wav";
if ($strFileType == ".mp3")
$ContentType = "audio/mpeg3";
if ($strFileType == ".mpg" || $strFileType == "mpeg")
$ContentType = "video/mpeg";
if ($strFileType == ".rtf")
$ContentType = "application/rtf";
if ($strFileType == ".htm" || $strFileType == "html")
$ContentType = "text/html";
if ($strFileType == ".xml")
$ContentType = "text/xml";
if ($strFileType == ".xsl")
$ContentType = "text/xsl";
if ($strFileType == ".css")
$ContentType = "text/css";
if ($strFileType == ".php")
$ContentType = "text/php";
if ($strFileType == ".asp")
$ContentType = "text/asp";
if ($strFileType == ".pdf")
$ContentType = "application/pdf";
Header("Content-Type: application/octet-stream");
Header("Content-Disposition: attachment; filename=".$strFileName);
Header("Content-length: ".filesize($file_location));
Header("Content-Description: downloaded from ".pnGetBaseURL());
Header("Content-Transfer-Encoding: binary");
//Sending the data...
readfile($file_location);
} //End of function