File Manipulation Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    File Manipulation Script

    <?php

    $filename = $_GET[&#39;file&#39;];

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

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

    if( $filename == "" )
    {
    echo "<html><title>WTF?</title><body>ERROR: download file NOT SPECIFIED. USE download.php?file=filepath</body></html>";
    exit;
    } elseif ( ! file_exists( $filename ) )
    {
    echo "<html><title>WTF?</title><body>ERROR: File not found. USE download.php?file=filepath</body></html>";
    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/lmao";
    }
    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");
    // change, added quotes to allow spaces in filenames
    header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    readfile("$filename");
    exit();

    ?>

    #2
    not bad that will hide the folder where the files are lol
    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      not bad that will hide the folder where the files are lol[/b]

      yeah mate.. but some phone models get errors when they download the file mate.. what could be the problem mate?

      Comment

      Working...
      X