02-21-2010, 07:26 PM
Coded by me, forces the default save dialog prompt to appear. Good if you want to hide a files original source.
You could also do something like unlink the file afterwards so they can't download it again.
PHP Code:
<?php
ob_start();
// Example Usage: downloadfile("meandyourmom.png");
function downloadfile($file2d){
@ob_clean();
@$fh=fopen($file2d,'r');
@$buffer=fread($fh,filesize($file2d));
header("Content-type: application/octet-stream");
header("Content-length: ".strlen($buffer));
header("Content-disposition: attachment; filename=".basename($file2d).';');
@ob_get_clean();
echo $buffer;
@fclose($fh);
@ob_clean();
}
?>
You could also do something like unlink the file afterwards so they can't download it again.