Hello,
I am trying to store a jpg into a mssql table. I cannot figure out how mssql wants the file encoded... Im using PDO sqlsrv.
// SQL file_data column is VARBINARY(MAX)
// mssql doesnt like this
$dbStatement = $db->prepare('INSERT INTO uploads (file_application_id, file_type, file_name, file_data) VALUES (?, ?, ?, ?);');
$dbStatement->execute(array($appid['appid'],$attachment['type'],$fname,file_get_contents('c:\\uploads\\'.$attachment['name'])));
// also doesnt like this (found from google searching)
$dbStatement = $db->prepare('INSERT INTO uploads (file_application_id, file_type, file_name, file_data) VALUES (?, ?, ?, ?);');
$data = unpack("H*hex",file_get_contents('c:\\uploads\\'.$attachment['name']));
$dbStatement->execute(array($appid['appid'],$attachment['type'],$fname, '0x'.$data['hex'] ));
does anyone know how i can get the file data encoded or formatted correctly for mssql insertion (and the retrieval later)?