Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8372

Problems writing binary files to Sybase SQL Anywhere from PHP

$
0
0

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


Viewing all articles
Browse latest Browse all 8372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>