This answer details how to use the upload page to register a download, and also start downloading a file as soon as someone clicks on the link. I recently checked it for a right click.
I am using php middle-man to upload files to a file. The formatted URL http://192.168.1.1/xfer.php?file=Li9zb25ncy9HTE9XX0xlYXZlIFlvdXIgSGF0IE9uLm1wMw results in a file name for both Save As ... and left-click in Firefox.
Here is my xfer.php
<? $filename = base64_url_decode($_GET['file']); if ($_GET['file']){ header("Cache-Control: public"); header("Content-Description: File Transfer"); header('Content-disposition: attachment; filename='.str_replace(" ", "_",basename($filename))); header("Content-Transfer-Encoding: binary"); header('Content-Length: '. filesize($filename)); readfile($filename); } $fh = fopen("test.html","a"); fwrite($fh,basename($filename)."\n<br />"); fclose($fh); function base64_url_decode($input) { return base64_decode(strtr($input, '-_,', '+/=')); } ?>
And the page that links to xfer.php,
$link = "xfer.php?file=".base64_url_encode("./songs/$key");
with $key being the file name, and songs is the folder where the file names are stored.
Grant Jan 30 '09 at 0:11 2009-01-30 00:11
source share