Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Problem with custom college up/download mod.
  • Posted: 07.05.2004, 16:03
     
    RangeR
    rank:
    Freshman Freshman
    registered:
     August 2002
    Status:
    offline
    last visit:
    11.08.05
    Posts:
    49
    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.

    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("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

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula