fread does not return the exactly size of bytes. You should process it manually while (!feof($fp)) { $chunk += fread($fp, 4 * 1024 * 1024); // chunk the file as 4MB while( $chunk.length >= 4M) { $chunk4m = $chunk.substring(0, 4M); fwrite(file, chunk4m) $chunk = $chunk.substring(4M) } }
|