Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Laravel在SQL Server中存储和检索图像?_Sql_Sql Server_Laravel_Laravel 4 - Fatal编程技术网

如何使用Laravel在SQL Server中存储和检索图像?

如何使用Laravel在SQL Server中存储和检索图像?,sql,sql-server,laravel,laravel-4,Sql,Sql Server,Laravel,Laravel 4,如何使用laravel存储和检索图像?我在sql server中有一个“image”数据类型的图像字段。我想保存图像并使用laravel检索它?在下面找到我使用过的代码 $img_path = Input::file('file') -> getRealPath(); $image_data = file_get_contents($img_path); $base64 = base64_encode($image_data); $logoTypes = new logoTypes; $l

如何使用laravel存储和检索图像?我在sql server中有一个“image”数据类型的图像字段。我想保存图像并使用laravel检索它?在下面找到我使用过的代码

$img_path = Input::file('file') -> getRealPath();
$image_data = file_get_contents($img_path);
$base64 = base64_encode($image_data);
$logoTypes = new logoTypes;
$logoTypes -> Type = "Image";
$logoTypes -> image = $base64;
$logoTypes -> created_by =  Auth::user()->id;
$logoTypes -> updated_by = Auth::user()->id;
$logoTypes -> save();
但是,我得到了以下错误

{"error":{"type":"Illuminate\\Database\\QueryException","message":"SQLSTATE[22018]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Operand type clash: nvarchar(max) is incompatible with image (SQL: insert into [logoTypes] ([Type], [image], [created_by], [updated_by], [updated_at], [created_at]) values (Image, \/9j\/4AAQSkZJRgABAQAAAQABAAD\/2wCEAAkGBxQSEhUUEhISFBQUFhQUFBQVFRQUFRQUFxQXFhQUFxQYHCggGBolHBQUITIhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGxAQGywkICQsLCwvLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLPMnEDzVTr3qpqgbmkfiA5qp2ILNOvOqqdeocA3NMcRXDiSyjsQ6ql2I9UNkV3Nc7FFwYwFjH4l1Q78S6qu6J3DcPxwDihax...., 1, 1, 2014-06-23 17:20:18.000, 2014-06-23 17:20:18.000))","file":"D:\\wamp\\www\\Lhrms\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php","line":555}}
只需使用Laravel Staper:

Laravel Stapper是Laravel框架的基于订书机的文件上载包。它可用于将文件上载(作为附件对象)添加到ORM记录中