Voting

: min(four, three)?
(Example: nine)

The Note You're Voting On

randym
13 years ago
Concerning [problems with UTF-8 and] downloading Zip files I found that simply adding 3 lines of code before starting the fread to the buffer for delivery in all browsers solved the problem.

<?php
ob_end_clean
();
ob_start();
header( 'Content-Type:' );
?>

... see where placed in the function below:

<?php
function readfile_chunked( $filename, $retbytes = true ) {
$chunksize = 1 * (1024 * 1024); // how many bytes per chunk
$buffer = '';
$cnt = 0;
$handle = fopen( $filename, 'rb' );
if (
$handle === false ) {
return
false;
}
ob_end_clean(); //added to fix ZIP file corruption
ob_start(); //added to fix ZIP file corruption
header( 'Content-Type:' ); //added to fix ZIP file corruption
while ( !feof( $handle ) ) {
$buffer = fread( $handle, $chunksize );
//$buffer = str_replace("","",$buffer);
echo $buffer;
ob_flush();
flush();
if (
$retbytes ) {
$cnt += strlen( $buffer );
}
}
$status = fclose( $handle );
if (
$retbytes && $status ) {
return
$cnt; // return num. bytes delivered like readfile() does.
}
return
$status;
}
?>

<< Back to user notes page

To Top