Jump to content

anti-hotlink Download script


joecooper

Recommended Posts

Put the exe out of the webroot and have the PHP file read the contents of it to the browser.

 

 

You will of course want to do some kind of checking in PHP to prevent hotlinking.  Perhaps have a token set in the SESSION array or something.  (If token is there and correct, you know they came from a previous page.)

 

Or, you could check referer or something.

Uh, it's the same kind of code that you would use to read a file, just you would put it out of the web root.

 

 

For example, if you had the following directory structure:

 

-public_html

--index.php

-files

--some.exe

 

In index.php, you could use ../files/some.exe as the path.

 

 

Or, if you could use absolute path:  /path/to/folders/files/some.exe

 

 

As for how to force a file download, with a filename:

 

http://www.phpfreaks.com/forums/index.php/topic,95433.0.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.