Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: File download

  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File download

    Hallo everyone, I'm desparate for this kind'a script..

    i've put a more than 15MB .PDF file on my server, i need a script that would speed up the downloading of that file.
    have a look@

    PHP Code:

    if($_GET['file']){
    $filename $_GET['file'];

    // required for IE, otherwise Content-disposition is ignored
    if(ini_get('zlib.output_compression'))
      
    ini_set('zlib.output_compression''Off');

    $file_extension strtolower(substr(strrchr($filename,"."),1));

    if( 
    $filename == "" 
    {
      echo 
    "::ERROR::";
      exit;
    } elseif ( ! 
    file_exists$filename ) ) 
    {
      echo 
    "::ERROR::";
      exit;
    };
    switch( 
    $file_extension )
    {
      case 
    "pdf"$ctype="application/pdf"; break;
      case 
    "exe"$ctype="application/octet-stream"; break;
      case 
    "zip"$ctype="application/zip"; break;
      case 
    "doc"$ctype="application/msword"; break;
      case 
    "xls"$ctype="application/vnd.ms-excel"; break;
      case 
    "ppt"$ctype="application/vnd.ms-powerpoint"; break;
      case 
    "gif"$ctype="image/gif"; break;
      case 
    "png"$ctype="image/png"; break;
      case 
    "jpeg":
      case 
    "jpg"$ctype="image/jpg"; break;
      default: 
    $ctype="application/force-download";
    }
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers 
    header("Content-Type: $ctype");

    header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    readfile("$filename");
    exit(); 
    * if it's impossible how can i compress that file to atleast smaller MBs or KBs?
    Please, HELP!

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts

    possible

    zip it, rar it, tar.gz it
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •