On Mon, Feb 25, 2008 at 10:39 PM, Manuel Barros Reyes <[EMAIL PROTECTED]> wrote:
[snip!]
> I guess the download is stoped by some timeout and not because of the
> amount of kb downloaded because the size varies slightly. If that
> timeout exists it should be of apox. 5-10 seconds.
Check the values in php.ini for the following:
default_socket_timeout
max_execution_time
memory_limit
And since you're uploading, also check these values in php.ini:
max_input_time
file_uploads
upload_max_filesize
Then, presuming you use Apache, check your httpd.conf file to see
if the value of Timeout is sufficient. The default is 300.
> I use this function to perform the upload $contenido is the content of
> the file and to that variable I assign the big chunk of output from
> the report, $nombre_archivo is the optional name for the file. I can
> paste more code but I think the problem is here.
Here's a rewrite of your function, which you can see working live
at http://www.pilotpig.net/code-library/stream-file-with-checking.php.
Sorry if my Spanish isn't very good in the code itself. :-\
<?
// Illustrates a way to serve a CSV file and ensure
// that the client is still active.
// Originally written for Manuel Barros Reyes on php-general
function enviarArchivo($contenido, $nombre_archivo = "") {
ignore_user_abort(1);
if($nombre_archivo == "") {
$nombre_archivo = date("dmyHi").".csv";
}
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$nombre_archivo");
header("Content-Length: ".strlen($contenido));
$arsenal_contenido = explode("\n",$contenido);
for($i=0;$i<count($arsenal_contenido);$i++) {
if(connection_status() != 0) {
$err = "La conexion ha estado cerrada. ";
$err .= "Estos datos no podian ser enviados:\n";
$err .= $arsenal_contenido[$i];
file_put_contents('error.txt',$err);
exit;
}
echo $arsenal_contenido[$i]."\n";
}
}
enviarArchivo(file_get_contents('test.csv'));
?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php