Hi moshiani & Bob,
The proof-of-concept code worked well enough on my platform, however something did cause data corruption on Chris'. Unfortunately, the source for this corruption was never determined, and I could never reproduce it on my platform.
Nevertheless, I'll give you an outline to get started with:
Since you do use the BLOB datatype, there should'nt be any concerns with character set translations.
Next, the data in $form->data['country']['map'] would be the raw binary data; there's no easy way for your browser to actually know this is an image, and not some random text. Simply echo'ing the content will just show a lot of odd characters (as you described).
What you need to do, is instruct your browser to treat this as an image instead. This can be done in two ways;
The most common way is to use the <img> element, pointing to an external resource. In this case, you'd use a separate php-script to do the database-read, and set the appropriate headers to instruct your browser that it's really an image:
<?php
$index = intval($_GET['id']);
$db = new mysqli("example.tld", "user", "password", "database");
if ($db->connect_errno)
die;
$query = $db->prepare("SELECT `map` FROM `jos_theTable` WHERE `id` = ? LIMIT 1");
$query->bind_param("i", $index);
$query->execute();
$query->bind_result($image);
if ($query->fetch())
{
header("Content-Type: image/png");
echo($image);
}
?>
You'd then add something like <img src="/path/to/script.php?id=X"> where X would be the id of the image to be displayed (I assumed it to be an integer here).
The other approach would be to use inline images. Keep in mind though, that this does not work for older browsers - especially IE 7 and older.
In this case, you'd have to base64-encode the image, and provide a modified value for the "src" attribute of the image element:
<img src="data:image/png;base64,<?php echo base64_encode($form->data['country']['map']); ?>"><
Worth mentioning though, is that the size for data-url's is rather limited; with opera maxing out somewhere around 4k, IE8 at 32k and firefox at 100k. Also, using base64 encoding adds an overhead of roughly 33%.
/Fredrik