• 0

[PHP] How To Hide A Download Location


Question

I have a download module that was made by someone else but only about 90% finished, I'd like to be able to hide the actual location of the file, as it is now when you hover over "click Here to download" you can see the actual location of the file... I would like to remove that if possible....

I believe this is the line that controls it, however there may be more, I'm not sure:

$msg = "Your download of <b>$title</b> should begin shortly.<br /><br /> If it doesn't, you can " . sprintf($lang['DL_Click_Download'], '<a href="' . append_sid("$url") . '">', '</a>');

Link to comment
https://www.neowin.net/forum/topic/57432-php-how-to-hide-a-download-location/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

It's very hard to hide the actual address as the web browser needs to know the actual address for it to be able to go there to download the file. This means you're relying on the visitor's computer to do something the visitor probably won't want to do. I'm no expert on this, but the title attribute (w3.org) should do the job if you don't want to block knowledgable people. I've never seen any way to block really knowledgable people as all browsers have a "View Source" option.

Try this - same code, but with the title attribute set:

$msg = "Your download of &lt;b&gt;$title&lt;/b&gt; should begin shortly.&lt;br /&gt;&lt;br /&gt; If it doesn't, you can " . sprintf($lang['DL_Click_Download'], '&lt;a href="' . append_sid("$url") . '" title="Click here to download!"&gt;', '&lt;/a&gt;');

I think that's it. It's a kinda weird piece of code.

  • 0

The easiest way to obsfucate a download link from the average user, is with the header() command:

header( "Location: [url=http://www.mywebsite.com/downloads/download.exe"]http://www.mywebsite.com/downloads/download.exe"[/url] );

Just change the url as neccessary. If you also want to get funky you can do some crazy stuff like a readfile() with header() for the content type. That should hide your file completely, but it's not the most easy one on the server :/

  • 0
  Quboid said:
timdorr - do you mean the download link should link to a PHP which just has that? Rather than obscuring it on the main page which I did, send it to another page that obscures it. That's a pretty good idea.

There are a few different ways to implement Timdorr's header() technique...

They way I would do it is have a script that handles the process. The initial link links to http://yoursite.com/downloadscript.php?id=666 or something like that. The script then, by whatever means you are current using to store these links, figures out what link to use in the header() function.

Sorry if that doesn't make sense, it sure doesn't to me as it's 4am.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.