title: MySQL PHP not storing full file to BLOB
body: <p>I have just set up a new LAMP server running CentOS 6, Apache 2.2.15, PHP 5.5.25 and MySQL 5.5.43. I installed php and mysql from webtatic and am using the mysqlnd extension.</p>
  
  <p>I have transferred over code and databases from a much older LAMP set up. Most of the site works fine and has transferred well.</p>
  
  <p>However the storage of files in the database has ceased to function properly. What I mean by this is that files are no longer being stored fully, the last roughly 20% is lost. I have spent quite a while trying to work out what the cause might be and am fairly confident it is happening at the "php saving to mysql" stage.</p>
  
  <p>In other words, the file makes it to the server full size, however by the time it hits the DB as a LONGBLOB it has lost some of it's size. But as I have to download it out of the DB to check it's size it could be an issue with the delivery of the file.</p>
  
  <p>I am using phpmyadmin for the moment and it and both my php code have exactly the same issue. No matter whether I use my uploader or that of phpmyadmin (via insert/edit choose file) the LONGBLOB filesize shown in phpmyadmin ends up being smaller than the original file.</p>
  
  <p>Then when I download it either via my file delivery or through phpmyadmins, the file is delivered at the correct dimensions but the bottom 20% is gray/white/colour.</p>
  
  <p>I'm totally stumped! I've tried messing with packet/memory/upload limits, collation formats and DB Engines. But I just can't get it to store/deliver the whole file.</p>
  
  <p>Anyone have any ideas?</p>
  
  <p>Let me know if you need more info to help.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Edit 1: I've now narrowed it down to it being a problem with PHP's delivery of files to the client's browser. For whatever reason when file content comes from a database field it is not delivered complete. As I mentioned, this happens with both my code and phpmyadmin. Any ideas?</p>
  
  <hr>
  
  <p>Edit 2: I've done a further test and can successfully write the file from the database to the server's filesystem using PHP. The file is complete! This can only mean the way PHP is sending the data from the database is the problem. But what's changed between my old and new server?</p>