【发布时间】:2017-05-19 07:15:10
【问题描述】:
我使用 php 创建网站并尝试将图像从地址插入到 sqlserver 数据库,我使用此代码:
function prepareImageDBString($filepath)
{
$out = 'null';
$handle = @fopen($filepath, 'rb');
if ($handle)
{ $content = @fread($handle, filesize($filepath));
$content = bin2hex($content);
@fclose($handle);
$out = "0x".$content;
}
return $out;
}
$out = prepareImageDBString('http://....com/img.jpg');
sqlsrv_query($conn,"INSERT INTO Imagess(imgtype) VALUES($out) ");
图像保存成功但不显示,我的意思是图像损坏保存 怎么做才能得救?
【问题讨论】:
标签: php html sql-server image insert