|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-03-28 08:33 UTC] javier dot sagrera at uk dot ibm dot com
[2017-09-30 17:51 UTC] josemalonsom at yahoo dot es
-Status: Open
+Status: Closed
[2017-09-30 17:51 UTC] josemalonsom at yahoo dot es
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 21:00:01 2025 UTC |
Description: ------------ When a binary file is inserted in a blob field the content is saved partially corrupting the file. Tested in a 32bit OS and it works fine but the file is not saved correctly when the platform is 64bit. PHP: tested in versions 5.4.45, 5.5.30 and 5.6.16. CSDK: 4.10.FC6DE Test script: --------------- // $con is a valid PDO_INFORMIX connection $base64BlobFile = 'UEsDBBQAAAAIABiIJEj+Q0o8DwAAABIAAAAJABwAZmlsZTEudHh0VVQJAA' . 'Mvl4pWaJeKVnV4CwABBOgDAAAE6AMAAMvJzEs15MoBkkZg0pgLAFBLAQIeAxQAAAAIABiI' . 'JEj+Q0o8DwAAABIAAAAJABgAAAAAAAEAAAC0gQAAAABmaWxlMS50eHRVVAUAAy+XilZ1eA' . 'sAAQToAwAABOgDAABQSwUGAAAAAAEAAQBPAAAAUgAAAAAA'; $blobFile = '/tmp/file1.zip'; file_put_contents($blobFile, base64_decode($base64BlobFile)); try { $con->exec('DROP TABLE blob_test'); } catch (Exception $e) {} $con->exec('CREATE TABLE blob_test (blob_column BLOB)'); $fh = fopen($blobFile, 'rb'); $stmt = $con->prepare('INSERT INTO blob_test (blob_column) VALUES (?)'); $stmt->bindParam(1, $fh, PDO::PARAM_LOB); $stmt->execute(); $stmt = $con->prepare('SELECT FIRST 1 blob_column FROM blob_test'); $stmt->bindColumn(1, $blob, PDO::PARAM_LOB); $stmt->execute(); $stmt->fetch(PDO::FETCH_BOUND); fseek($fh, 0); $expectedContent = stream_get_contents($fh); $actualContent = stream_get_contents($blob); print $expectedContent == $actualContent ? "Test ok\n" : "Test fail\n"; Expected result: ---------------- The file should be inserted correctly. Actual result: -------------- The inserted file is corrupted.