PHP Downloaded File does not match Server File size
<p>I use a simple code in PHP to download a file and calculates its MD5 to verify the download was completed as expected, but I have noticed that PHP even when it is downloading a healthy, complete file, it is slightly bigger than the one in the server for few bytes, hence causing the MD5 check to fail.</p>

<p>This is the PHP code I'm using:</p>

<pre><code>&lt;?php
$path_parts = pathinfo($_GET['a']);
$file_name  = $path_parts['basename'];
$file_path  = 'temp/' . $file_name;

if (file_exists($file_path)) {
    $size = filesize($file_path);

    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename=$file_name");
    header("Content-Type: application/zip");
    header("Content-length: $size");
    header("Content-Transfer-Encoding: binary");

    // read the file from disk
    readfile($file_path);
}    
else
    echo 'File does not exists';
?&gt;
</code></pre>

<p>In the server I have a .ZIP file which weights 203 bytes, but the downloaded file is 254 bytes or higher. So, what am I doing wrong that can't make the PHP to download a complete simple file?</p>

<p>To download the file I use <code>C# WebClient</code> or Goolgle-Chrome and I get the same result in both.</p>