0

i was wondering, when someone is downloading a file, lets say a .zip file, is it possible to hide the url where the .zip is stored? I use a link to the .zip file to download it like this:

<a class="BigButton"href="http://www.webprofis.nl/demo/vd/1/validation- contactform/validation-contactform.zip">DOWNLOAD contactform </a>

When mouseover the link, everybody can see where the file is stored...

2 Answers2

0

You can do this only with javascript. Here is a little example with jQuery:

<a href="#" data-link="http://your_download_link">Download link</a>
<script>
$('a[data-link]').click(function(e) {
   e.preventDefault();
   window.open($(this).attr('data-link'));
});
</script>
Ibrahim
  • 2,034
  • 15
  • 22
  • No. Anyone that wants to get the actual URL can just disable JavaScript. – Eric J. Apr 30 '14 at 19:44
  • Even with javascript disabled, the link won't be displayed on hover. Of course, any user can get the link if they look in the source, but to prevent that you can't use only javascript. An alternative way is to always put a link to a php script identified by an id, and from that script you can redirect the user to the original link, which will be stored in a database. – Ibrahim Apr 30 '14 at 19:51
0

If you make the href='#' then add an onclick event you could use javascript to redirect the user to the zip file. However, if something views the source of your page it'll still show it there.

Colum
  • 996
  • 2
  • 8
  • 23
  • No. Anyone that wants to get the actual URL can just disable JavaScript. – Eric J. Apr 30 '14 at 19:44
  • 1
    I didn't know that. So just to help me understand, what will disabling javascript actually cause to happen that they will see it? Would it not be easier to view source? – Colum Apr 30 '14 at 19:49
  • Well, the user would see the link as being '#', and the actual URL would be in the source. Point is, it is easily accessible so JavaScript is never a solution to hiding a link. Needs to happen server-side, as shown in the "close as duplicate" link. – Eric J. Apr 30 '14 at 19:52
  • So your first comment was in fact wrong? And I know that, hence why I wrote : "However, if something views the source of your page it'll still show it there." the server-side tip is handy, so thank you :) – Colum Apr 30 '14 at 20:26