Google analytics code

Wednesday, February 13, 2008

PHP: Code snippet

I found this on a page written in japanese. Great for streaming files through php and not reveling their source.
http://phpspot.org/blog/archives/2008/02/phpdlphp.html

header('Content-Type: application/octet-stream');
header('Content-Disposition: filename=dl.zip');
header('Content-Length: '.filesize('dl.zip'));
echo file_get_contents("dl.zip");
?>

This will also post the size of the file so you know how long it will take for it to download.

No comments:

Post a Comment

If you found this page useful, or you have any feedback, please leave a comment.