#47982 [NEW]: Storing image binary data

From: Date: Thu, 16 Apr 2009 08:46:49 +0000
Subject: #47982 [NEW]: Storing image binary data
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135865@lists.php.net to get a copy of this message
From: markac at home dot pl Operating system: XP PHP version: 5.2CVS-2009-04-16 (snap) PHP Bug Type: PDO related Bug description: Storing image binary data Description: ------------ PDO adding extra bytes (F3 F3 F3 F3) to begining binary data. I'm use SOAP extension to retrieving data from client. When I save data to file or using MySQL directly, all is ok. When I use PDO to store the same data to column (MySQL), PDO adding extra data and image is broken. Reproduce code: --------------- $server = new SoapServer('file.wsdl', array('cache_wsdl' => WSDL_CACHE_NONE)); /* Connect to an ODBC database using driver invocation */ $dsn = 'mysql:dbname=db;host=localhost;charset=UTF-8'; $user = 'root'; $password = ''; $pdo = new PDO($dsn, $user, $password); $pdo->exec('SET CHARACTER SET utf8'); //NOT WORK! Adding Image is broken $sth = $pdo->prepare('UPDATE users SET avatar = :avatar WHERE id = :id '); //$avatar is server function argument. See $server->addFunction('UpdateUser); $sth->bindParam(':avatar', $avatar, PDO::PARAM_LOB); $sth->bindParam(':id', $user->id, PDO::PARAM_INT); return $sth->execute(); //THIS WORK! file_put_contents('image.jpg', $user->avatar); /* AND THIS WORK! mysql_query('update users set avatar = "' . addslashes($user->avatar) . '" where id = ' . $user->id); */ $server->addFunction('UpdateUser); $server->handle(); Sorry for my english. -- Edit bug report at http://bugs.php.net/?id=47982&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47982&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47982&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47982&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47982&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47982&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47982&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47982&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47982&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47982&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47982&r=support Expected behavior: http://bugs.php.net/fix.php?id=47982&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47982&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47982&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47982&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47982&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47982&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47982&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47982&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47982&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47982&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47982&r=mysqlcfg

« previous php.bugs (#135865) next »