Skip to content

Instantly share code, notes, and snippets.

@JackZielke
Created February 25, 2022 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackZielke/a161114254f988fe5a933c7356865029 to your computer and use it in GitHub Desktop.
Save JackZielke/a161114254f988fe5a933c7356865029 to your computer and use it in GitHub Desktop.
Generate 128M file for download testing without using 128M of space
<?php
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
header('Expires: '.gmdate('D, d M Y H:i:s', 0).' GMT');
header('Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, FALSE');
header('Pragma: no-cache');
header('Content-Disposition: attachment; filename="test.file"');
header('Content-type: application/octet-stream');
header('Content-Length: 134217728');
flush();
$s='0';
// 128k block
for($i = 0 ; $i < 17 ; $i++)
{
$s .= $s;
}
// 128M output
for($i = 0 ; $i < 1024 ; $i++)
{
echo $s;
flush();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment