joecooper Posted February 7, 2009 Share Posted February 7, 2009 I have a exe file on my site for download. i want the file only to be downloaded via a php script, and not hot-linked. could someone point me in the right direction as to what i would need for this? I wish to also log downloads with this script. Link to comment https://forums.phpfreaks.com/topic/144255-anti-hotlink-download-script/ Share on other sites More sharing options...
corbin Posted February 7, 2009 Share Posted February 7, 2009 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. Link to comment https://forums.phpfreaks.com/topic/144255-anti-hotlink-download-script/#findComment-757047 Share on other sites More sharing options...
joecooper Posted February 7, 2009 Author Share Posted February 7, 2009 Put the exe out of the webroot and have the PHP file read the contents of it to the browser. I think i done somthing like that a long time ago with JPG images, could you point me to some example code? Link to comment https://forums.phpfreaks.com/topic/144255-anti-hotlink-download-script/#findComment-757062 Share on other sites More sharing options...
corbin Posted February 8, 2009 Share Posted February 8, 2009 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 Link to comment https://forums.phpfreaks.com/topic/144255-anti-hotlink-download-script/#findComment-757109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.