If you do it with PHP, you'll have to always link to the same PHP file and tell it which file to server. <a href="download.php?file=file.jpg">File</a> download.php:
<?php// Make sure only files in this directory are accessible by removing slashes$file = str_replace('/','',$_GET['file']);$file = str_replace('\\','',$file);// If the file doesn't exist, show an error message and leaveif(!file_exists('downloads/' . $file) { header("HTTP/1.0 404 Not Found"); echo 'The selected file doesn\'t exist'; exit;}// Tell the browser to download the fileheader('Content-type: application/octet-stream');header('Content-Disposition: attachment');// Output the file dataecho file_get_contents('downloads/' . $file);?>