I am looking for a way to convert an image base64
to varbinary
a through PHP
.
I am trying to convert it as follows by doing a successful insert in MSSQL
:
CONVERT(VARBINARY(MAX),$_POST(['imgBase64']) //Un trazo cualquiera
But when trying to encode it to show it again as an image, it appears as if it doesn't exist and the result base64_encode($imagen)
is totally different from the original...
Entrada: iVBORw0K...kJggg==
varbinary almacenado: 0x6956424F52773...545726B4A6767673D3D
Salida: aVZCT1J3MEtHZ2...JrSmdnZz09
Other images already stored in the database are displayed correctly, but it does not work with the new ones that I am trying to insert.
What is the correct way to do the conversion from base64
to varbinary
?