The way you're creating your link gives you no control as to where the browser should look for the file. Your generated link is a relative link, meaning that the browser will look for the file in the current location. So if your current URL is
http://example.com/index.php/component/subscription/, the file will be looked for in
There are several ways to get around this, depending on your needs. Let's say the file is located on your server in the
<a href="http://example.com/mydownloads/<?php echo $filepath; ?>"> download </a>
This will work, but only if the domain is always the same. If you move your site or change domain, the link will break.
<a href="/mydownloads/<?php echo $filepath; ?>"> download </a>
/ will tell your browser to start looking from the top domain, whatever that is. The advantage is that it will work even if you change domains. The disadvantage is that if your Joomla installation is located in a subfolder of your domain (http://example.com/joomla), the link will still point to
Option 3 (preferred method)
<a href="<?php echo JURI::base() ?>mydownloads/<?php echo $filepath; ?>"> download </a>
JURI::base() returns the complete path of your Joomla installation, whatever domain or subfolder it's located in. Using this method, you can generate an absolute link that always works. Note that the URI returned has a trailing "/".