Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- $url = 'http://mirror.isoc.org.il/pub/fedora/releases/17/Live/x86_64/Fedora-17-x86_64-Live-Desktop.iso';
- $file_name = 'Fedora-17-x86_64-Live-Desktop.iso';
- header('Content-Type: application/octet-stream');
- header("Content-Disposition: attachment; filename=" . $file_name);
- ob_end_flush();
- // Headers function
- // You should able to send from here also the content length header with the data from the headers param but its not working as expected ATM
- function handle_headers($ch, $headers) {
- return strlen($headers);
- }
- // Output function
- function output_chunk($ch, $data) {
- echo $data;
- flush();
- return strlen($data);
- }
- $ch = curl_init($url);
- curl_setopt_array($ch, array(
- // CURLOPT_HEADERFUNCTION => 'handle_headers',
- CURLOPT_WRITEFUNCTION => 'output_chunk',
- // CURLOPT_RETURNTRANSFER => true,
- // 1 MB
- CURLOPT_BUFFERSIZE => 500000,
- CURLOPT_HEADER => false
- ));
- curl_exec($ch);
Add Comment
Please, Sign In to add comment