I am trying to stream a movie file with 'fread'
this my first step in trying to dynamically encrypt the file as it is being
streamed from the server
do I need to fread the data in chunks?
If so, how?
$filename ="$path2file";
$file = fopen($filename,'r');
$fileSize = filesize($filename);
$ContentType = " video/quicktime";
header ("Content-type: $ContentType");
header ("Content-length: $fileSize");
while( $filedata_temp = fread($file, $fileSize) )
echo $filedata_temp;
<b>Fatal error</b>: Allowed memory size of 16777216 bytes exhausted (tried
to allocate 24113191 bytes) in <b>xxxxxxxx/fopenTest.php</b> on line
<b>27</b><br />
Not knowing exactly what you're trying to accomplish...
I'm guessing that your $filename file is 24113191 in size and that PHP is
compiled with a memory limit of 16777216. And since your assigning the
results of fread() to a variable, PHP is going to try an allocate that for
you and is failing.
Couple of points..
Why loop if you are reading the entire file at once? Which is what
fread($file, $fileSize) is going to do?
Instead perhaps you want this:
while ( !feof($file) ) {
echo fread($file, 32768);
}
(or some other value for 32768...)
That keeps the memory usage down, but does the same thing...
good luck!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php