Uploading pdf to Image data column in SQL
Hi, I have a requirement to upload pdf documents into an Image data type column within my sql database. I know that its better practice to store images as file locations, but this is an old database and is very integrated into the current ecosystem so I'm not able to make that change.
Here is the code that I am currently using:
$documentImage = new documentImage(); $documentImage->Data = '0x'. unpack("H*hex",Storage::disk('public')->get($request->fName))['hex']; $documentImage->FileType = 'pdf'; $documentImage->FileName = $request->fileName; $documentImage->DateCreated = Carbon::now(); $documentImage->DocumentType = 'M'; $documentImage->save();
However, I get the following error:
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Operand type clash: nvarchar is incompatible with image
Please or to participate in this conversation.