2016-07-22 39 views
0

我的数据库开发人员让我使用SQL表中的字段作为图像类型。 我试图把图像有人上传,只是将其插入在php中为图像写入插入语句

$imagePath = Input::file('image'); 
$image  = $imagePath->getPathName(); 

$图像返回临时路径名

$file = fopen($image, "rb"); 
$content = fread($file, filesize($image)); 
fclose($file); 

$SqlConn = "INSERT INTO [poll14] ([image]) VALUES ($content)"; 

但我得到这个错误:发生错误代替命名参数。 我该如何插入数据?

+0

' “INSERT INTO poll14(图)VALUES( '$内容')”' – JustOnUnderMillions

+1

您还需要了解,理解并开始使用参数化查询。你在这里有什么是开放的SQL注入。 –

回答

0

试试这个,它类似于您的要求here

insert into poll14 (ImageColumn) 
SELECT BulkColumn 
FROM Openrowset(Bulk 'image..Path..here', Single_Blob) as img 
+0

这很好。现在我该如何在存储过程中实现这一点? – user1899829

+0

@ user1899829你是否设法让存储过程工作? 您忘记接受答案 – singhswat