I have a software app that checks for updates and downloads them from http://www.some_random_website.com/updatefile.rar
However, I’ve noticed that ISPS tend to cache these files so the software app isnt always getting the latest file.
step 1 – create a php function to download a file
<?php $filename = $_GET['filename']; $path = $_SERVER['DOCUMENT_ROOT'] . "/$filename"; if ($fd = fopen($path, "r")) { $fsize = filesize($path); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"" . $filename . "\""); header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly while (!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose($fd); ?> |
step 2 – rewrite urls so that when requesting /some_file.rar, it redirects to the php app as defined
Options +FollowSymlinks RewriteEngine on RewriteRule ^(.+)\.rar$ ./getfile.php?filename=$1.rar [NC] |

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 