I have to pass a function in visual basic to PHP to read this image saved in MySQL. I have tried several things but I did not do it in the database MySql it is currently saved: https://www.pastiebin.com/5bbba9dbc63f6#&togetherjs=73xi1xwALu
'Save string a Byte in MySql
Public Function StringaByte(cTexto As String) As Byte()
Dim aByte() As Byte
Dim aHexa() As String
Dim i As Long
aHexa = Split(cTexto, "&H")
ReDim aByte(UBound(aHexa) + 1) As Byte
For i = 0 To UBound(aHexa) - 1
DoEvents
aByte(i) = CLng("&H" & aHexa(i + 1))
Next
StringaByte = aByte
End Function
'Load hexa in MySql an conver to Byte
Private Function ByteaString(aByte() As Byte) As String
Dim i As Long
Dim cHex As String
cHex = ""
For i = 0 To UBound(aByte)
DoEvents
cHex = cHex & "&H" & Hex(aByte(i))
Next
ByteaString = cHex
End Function
in PHP I tried function hex2bin and pack
<?php
//header("Content-type: image/gif");
header("Content-type: image/jpg");
$img2="CODE HEXA IN LINK";
function hextobin($hexstr){
$aHexa = explode("&H", $hexstr);
$count=count($aHexa);
$aByte="";
for ($x=0;$x<$count; $x++){
@$aByte .="&H".hex2bin($aHexa[$x]);
}
return $aByte;
}
$acomulo= hextobin($img2) ;
echo base64_decode($acomulo);exit;
//echo $acomulo;exit;
?>
other example in php
<?php
$img2="CODE HEXA IN LINK";
function hextobin($hexstr) {
$aHexa = explode("&H", $hexstr);
$count = count($aHexa);
$aByte = "";
for ($x = 0; $x < $count; $x++) {;
@$aByte .=pack("H*", $aHexa[$x]);
}
return @$aByte;
}
$acomulo = hextobin($img2);
header("Content-type: image/gif");
echo base64_decode($acomulo);
exit;
?>