Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $action = isset($_GET['action']) ? $_GET['action'] : NULL;
- if ($action == 'file-end') {
- session_write_close();
- $str = "This is a fairly large file\n";
- header('Content-Type: text/plain');
- header('Content-Length: '.(strlen($str) * 1000000));
- header('Content-Disposition: attachment; filename="largefile.txt"');
- for ($i = 0; $i < 1000000; $i++) {
- echo $str;
- }
- } else if ($action == 'file-noend') {
- $str = "This is a fairly large file\n";
- header('Content-Type: text/plain');
- header('Content-Length: '.(strlen($str) * 1000000));
- header('Content-Disposition: attachment; filename="largefile.txt"');
- for ($i = 0; $i < 1000000; $i++) {
- echo $str;
- }
- } else if ($action == 'click') {
- echo "
- You clicked the link<br>
- <a href='?action=null'>back</a>";
- } else {
- echo "
- <a href='?action=file-end'>End the session and get the file</a><br>
- <a href='?action=file-noend'>Get the file without ending the session</a><br>
- <a href='?action=click'>Click the link</a>
- ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement