How to Store and Retrieve Image in SQL Server Using Laravel? -
how store , retrieve image using laravel? have image field of "image" datatype in sql server. save image , retrieve using laravel? find below code have used.
$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(); but, i'm getting next error,
{"error":{"type":"illuminate\\database\\queryexception","message":"sqlstate[22018]: [microsoft][sql server native client 11.0][sql server]operand type clash: nvarchar(max) incompatible image (sql: insert [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}}
just utilize laravel staper: https://github.com/codesleeve/laravel-stapler
laravel-stapler stapler-based file upload bundle laravel framework. can used add together file file uploads (as attachment objects) orm records.
sql sql-server laravel laravel-4
No comments:
Post a Comment