Greetings from Ireland,
I'm having a problem. I wrote this custom module for a college that allows lecturers to upload their notes so that their students can then download them. Everything works fine with one exception. Downloading an
HTML file triples the content in the one file.
e.g. If there is a 5KB
HTML file uploaded, it is 15KB after download and the file contains the exact data three times.
Has anyone seen this, or have any info on fixing it? Source Code below that downloads the file.
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("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Type: $ContentType");
header ("Content-Disposition: attachment; filename=$strFileName");
@
readfile ($file_location);
}
Regards
Keith Burke
Dublin, Ireland