1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<?php set_time_limit(0); if(isset($_GET['id']) && !empty($_GET['id'])){ $fakeFileName= $_GET['id']; // change the file name $realFileName = $_GET['id']; $file = "".$realFileName; // file url. $fp = fopen($file, 'rb'); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$fakeFileName"); header("Content-Length: " . filesize($file)); fpassthru($fp); } ?> [/cc] <strong>If above code is not working so try this</strong> [cc] <?php if(isset($_GET['id']) && !empty($_GET['id'])){ $fakeFileName = $_GET['id']; // change the file name $realFileName = $_GET['id']; $file = "".$realFileName; // file url. header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"".$fakeFileName."\""); ob_clean(); flush(); readfile($file); exit; } ?> |
Leave a reply