httpd-users-de mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Gerharz <li...@cgerharz.de>
Subject Re: Dateien vor direktem Zugriff schützen
Date Tue, 18 Jul 2006 23:57:44 GMT
Hallo Andreas,

ich zitiere einen Kommentar von Rob Funk im PHP-Manual von readfile()
<http://php.cgerharz.de/readfile>:

> When using readfile() with very large files, it's possible to run into problems 
> due to the memory_limit setting; apparently readfile() pulls the whole
file
> into memory at once.
> 
> One solution is to make sure memory_limit is larger than the largest file you'll 
> use with readfile().  A better solution is to write a chunking readfile.
> Here's a simple one that doesn't exactly conform to the API, but is close
> enough for most purposes:
> 
> <?php
> function readfile_chunked ($filename) {
>   $chunksize = 1*(1024*1024); // how many bytes per chunk
>   $buffer = '';
>   $handle = fopen($filename, 'rb');
>   if ($handle === false) {
>    return false;
>   }
>   while (!feof($handle)) {
>    $buffer = fread($handle, $chunksize);
>    print $buffer;
>   }
>   return fclose($handle);
> }
> ?>

Hoffe, ich konnte dir helfen.

Viele Gruesse,
Chris



--------------------------------------------------------------------------
                Apache HTTP Server Mailing List "users-de" 
      unsubscribe-Anfragen an users-de-unsubscribe@httpd.apache.org
           sonstige Anfragen an users-de-help@httpd.apache.org
--------------------------------------------------------------------------


Mime
View raw message