BLOB Field only gets 4K bytes of data, the remaining is missing.

The code below is getting a VarBinary field from MSSQL, but it only retrieves 4K of data, not the whole information in the field.
What do i need to do in order to get all the Data in my VarBinary field ?

$tsql = "select file_data,file_name from rfq_detail where file_data is not null and id_master=".$p_rfq_id;
sc_select(my_data,$tsql);	
if ({my_data} == true)
{
	while(!$my_data->EOF)
	{
		$binary_data = $my_data->fields[0];
		$file_name = $Root ."/". $p_rfq_id . '_' . $my_data->fields[1];
		$fh = fopen($file_name, "wb");
		fwrite($fh,$binary_data);
		fclose($fh);
		$mail->AddAttachment($file_name);
		$my_data->MoveNext();
	}
	$my_data->Close();
}

Thanks in advance…

What drive are you using to connect with your mssql?

If is ODBC, open your php.ini and check for this directive: odbc.defaultlrl

Its there thats setting 4096(4k)

I am using MSSQL Server driver.
So i do not know how to retrive the remaining data…
is there a function to tell the database field to get all ?

Thanks in advance…

No because this isnt a database(server side) problem. Its a drive problem.

Can you try connecting with SRV? Its a new dirver, more fast and reliable.

Or, check this thread: http://stackoverflow.com/questions/4500506/php-is-truncating-mssql-blob-data-4096b-even-after-setting-ini-values-am-i-m
"
0
down vote
I know this is ancient, but I solved this differently. ini_set does not wok for mssql.textlimit or mssql.textsize, this is documented on php.net.

Both of these default to 4096b (4k) in the php.ini file. Reset these to a higher value and it will work fine.

Dont forget to restart httpd service after."

Try change this directive on your php.ini: odbc.defaultlrl, mssql.textlimit, mssql.textsize. The default of all directives are 4096.
Restart apache (or windows :-p)