Hi there,

First post so take it easy on me! 🙂

I'm sorry if this has already been answered, I ran a search but with no success. What I wish to do is create a script which can mask the file name of downloads.

e.g, something like "<a href='getdownload.php?id=34'>Download Link</a>". I then wish the download to start in the same window without navigating away from the current page. I can take care of the databasing myself.

If you don't understand what I mean, this website is a perfect example of what I wish to achieve: http://www.nsplayer.net/downloads.php?s=&catid=16.

Any help will be greatly appreciatd! 🙂

    Assuming you have some way of matching up "id=34" with the path of a file, in your download script you could do something like:

    <?php
    
    // I'll assume $path is a (relative or absolute) path to the file to be downloaded
    $filename = basename($path);
    
    if(file_exists($path)) {
        header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header ('Content-Type: application/octet-stream');
        header ('Content-Length: ' . filesize($path));
        header ("Content-Disposition: attachment; filename=\"$filename\"");
    
    $fp = fopen($path,'rb');
    while(!feof($fp))
        echo fgets($fp, 8192);
    
    fclose($fp);
    } else {
        // error msg - file not found
    }
      Write a Reply...