From: filmixt at gmail dot com Operating system: Centos PHP version: 5.2.9 PHP Bug Type: Reproducible crash Bug description: forcing download +2mb
Description: ------------ Hi everyone, This is the first time I post here, I hope you could help me with a hard one. I'm making a project, where I have to force the download and print the content of a 700mb-1gb file. Problems? Well, a lot. Why? You'll see.. :D If we do this: [code=text]// FILE EXTERNAL[] $f = $_GET["f"]; // Size function urlfilesize($url,$thereturn) { $x = array_change_key_case(get_headers($url, 1),CASE_LOWER); $x = $x['content-length']; return $x; } // Getting size $peso = urlfilesize($_GET[f],''); // Headers header("Content-Type: application/download"); header("Transfer-Encoding: chunked"); header("Content-Disposition: attachment; filename=\"$f\"\n"); header("Content-Length: ".$peso); readfile($f);[/code] Once you get to 2MB, the download stops, why?, php hangs. I've been 4 days looking for an answer or a fix, and I failed. Imagine how I am :) This script is very easy, lets go onto a harder one... not too much: [code=text]// ARCHIVO $f = $_GET["f"]; // PESO function urlfilesize($url,$thereturn) { $x = array_change_key_case(get_headers($url, 1),CASE_LOWER); $x = $x['content-length']; return $x; } // Tengo PESO $peso = urlfilesize($_GET[f],''); // Headers $name = explode("/", $f); $nc = count($name); $nombre = $name[$nc-1]; header('Content-Description: File Transfer'); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=\"$nombre\"\n"); header("Content-Length: ".$peso); set_time_limit(0); function readfile_chunked($filename,$retbytes=true) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $cnt =0; // $handle = fopen($filename, 'rb'); $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; if ($retbytes) { $cnt += strlen($buffer); } } $status = fclose($handle); if ($retbytes && $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; } readfile_chunked($f,$peso);[/code] Buffer? The same, it hangs at 2MB. :D Now what? I tried: [code=text]header("Content-Type: application/download"); header("Transfer-Encoding: chunked"); header("Content-Disposition: attachment; filename=\"$f\"\n"); header("Content-Length: ".$peso); header("Location: $f");[/code] Funny? Well.. desperate. It doesnt work, it just redirects ;-) I tried to install lighttpd module, and it just works with LOCAL files, haha, not useful... So, in conclusion, Im f**ked up. I hope there's a master here to show us the way, or someone with an idea, because I can't handle more... Thanks everyone for the time. Expected result: ---------------- Download the file completelly. Actual result: -------------- It hangs at 2mb -- Edit bug report at http://bugs.php.net/?id=48517&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48517&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48517&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48517&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48517&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48517&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48517&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48517&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48517&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48517&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48517&r=support Expected behavior: http://bugs.php.net/fix.php?id=48517&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48517&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48517&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48517&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48517&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48517&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48517&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48517&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48517&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48517&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48517&r=mysqlcfg