$statement = $this->pdo->prepare("INSERT INTO {$this->table} (path, contents, size, type, mimetype, timestamp) VALUES(:path, from_base64(:contents), :size, :type, :mimetype, :timestamp)");
$statement->bindValue(':contents', base64_encode($contents), PDO::PARAM_LOB);
When inserting binary data (images) the data sometimes is malformed, I think it is caused by this bug:
https://bugs.php.net/bug.php?id=47982
One workaround is to use
base64_encode: