Sorry, that's for testing purpose.
Now i roughly have an idea, which is I convert the image into hex file and save into MSSQL. For some reasons, I don't know why when I browse the data using MSSQL Server management studio, it was converted into decimal. However, when I pull the data out from database, it's converted back into hex file again.
converting image into hex: [upload.php]
Code: Select all
$dataString = file_get_contents($uploadfile);
//$samething = bin2hex($dataString);
$arrData = unpack("H*hex", $dataString);
$contents = "0x".$arrData['hex'];
//$contents = base64_encode($contents);
$query = "INSERT INTO alenn_tblrotator VALUES ('" . $contents . "')";
This is the code that the raw image (in hex) pull out from the database and converting back into binary using pack() function
Code: Select all
$row = mssql_fetch_assoc($result);
$db_img = $row['imgdata'];
$db_img = pack("H" . strlen($db_img), $db_img);
header("Content-Type: image/jpeg");
echo $db_img;
it shows the result when i browse the page source: [showimage.php]
?????JFIF???d?d?????Ducky???????????Adobe?d?????????
???X?????????????????????????????????!1AQaq"???2BR#???br3$??C?Scs4???%?T????!1AQaq"2??#?B3??Rb?r????????Qp?@ ??@ ??@ ??@ !H??
(???DA? (?@ t (?@??@ 6???@ ??@ ??@ ???
(???J ?????@ v?8?@ *???
?*??@UTP@??@ v?@?q??@ ??(???
???@ ??@ Pu*??T??@ ??@ %@?8Pq@
B???@ ??@ ????@ ??@ ??@ P?#?8Pq@
B???@ ??@ ??@ ??@ ??@ ??@ J?
Gj???? ?(?@ ??@ ??@ ??@ ??@ ??@??@ H
@ ??@ ??@ ??@ ??@ ??@ ???@ ???@ ??H?@???@ ??@ ??@ ??@ ??@??@ ??@ ?(? )??@ ??@ ??@ ??@ ??@ ???@ ??R?@)??H????v?X?1??ZW?]??2?6ù[0???????k^|?N+9?/d?;?????Q>??HZ*??????Y???I"_???
3S??j0Y???c???(Rm??<??]QCQ?H8?J?qO
nK;???75?7R???M??<????@ ??@ ??@ T??@ ??@ @ ??g?d?=I?1@?ds?m9???}fj?m?C??n?T?bhc@??h??7?K?'ed?"K?4??)?O%?$?+?U???J\?3-?]?d[^&??/??g??h"_Qn?u1???}??r???3?wE?7?Y?0c???R?4`3???u????6?\c???!?fOk%?2B50??n#??p???^??g?Bo?b??1??n?3?x????_o??e???X?K???c?"Z?;??.\?%??@ ??@ ??@ ???@
@?H ????R??????&?U??)????,?Z????<O??????-?4?_??G?!?Z)??3?????:a?Y?i5????11??s$
y?c???I?Mv_??
?|U???7C??n?'????6???4V?\??M???|???#?[2o{Ks????????dM
p?
???
?????y??Z?Z? ??F?p??O?w,9.K???z????yG?A??/e???@ ??@ ??@ ???@ P @ ?v8?+?q???d???~?G?Z?$???|?w
?????U??t,n?r?S?]Q?S??KhN?q?
I then use this html tag to view the image: [viewimage.php]
Code: Select all
<img src="showimage.php" width="100" height="80"/>
But, the image is still not showing!! I have no idea at all as I've been doing research for this issue for 3 days already. Do I still miss out something in between???