I try to use the following code to upload a Word document to SQL Server's image column "Document" which can store binary file.
define("MAX_SIZE",3000000);
$handle = fopen($uploadwordfile, "rb") or die( "Can't open this Word file!" );
$data = base64_encode(fread($handle, MAX_SIZE));
$sql_loadfile = "insert into Media (number, Document) values (1,'".$data."')";
$condata->Execute($sql_loadfile) or die($condata->ErrorMsg());
fclose($handle);
$uploadwordfile is the local address of the document file. I try a 3-page text file which is OK but doesn't work for a one-word Word file. It look like the encoded $data is truncated in $sql_loadfile.
Anyone can help?