masking download locations

Discussion in 'Programming' started by jasonwilks, Jan 15, 2007.

  1. #1
    I was wondering if anybody knows how to simply mask a download, so users do not know where exactly they are downloading it from.

    That is all I want. Can somebody make me a simply script of some kind that I can do this? Thanks for any help!
     
    jasonwilks, Jan 15, 2007 IP
  2. deviataz

    deviataz Active Member

    Messages:
    179
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    75
    #2
    Well there's nothing, 'simple' about it...I've done it using a heavily modified CGIProxy script, but its pretty bandwidth intensive...What are your needs, specifically..?
     
    deviataz, Jan 15, 2007 IP
  3. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I use:
    $filePath = '/home/path/to/file.rar';
    $fileTitle = 'Pie.rar';					 //file will save as this value
    header('Content-Description: File Transfer');
    header('Content-Type: application/force-download');
    header('Content-Length: ' . filesize($filePath));
    header('Content-Disposition: attachment; filename=' . str_replace(' ', '_', $fileTitle));
    
    // Chunking function from php.net
    
    function readfile_chunked ($filename) {
      $chunksize = 1*(1024*1024); // how many bytes per chunk
      $buffer = '';
      $handle = fopen($filename, 'rb');
      if ($handle === false) {
       return false;
      }
      while (!feof($handle)) {
       $buffer = fread($handle, $chunksize);
       print $buffer;
       flush();
      }
      return fclose($handle);
    }
    
    set_time_limit(0);
    readfile_chunked($filePath);
    PHP:
     
    rodney88, Jan 15, 2007 IP