Hi there
We are trying to write PDF, Word, JPG and other binary files to a Sybase SQL Anywhere database using PHP.
We are connecting with PHP using PHP_DBLIB through PDO and are using the code below to read and a file and write into a column:
<?php
// Read file
$filename = “/path/to/file/pdf.pdf";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
// Attempt to write file
$query = $db->prepare('INSERT INTO table_name (id, document_blob) VALUES (1, ?)’);
$query->bindParam(1, $contents, \PDO::PARAM_LOB);
$query->execute();
?>
The whole query just fails with a generic error message, however we are able to use the above code to write to a MySQL database.
Any thoughts / inspiration gratefully received.
Cheers
Ed