Javascript: save image into mysql and shows it later into html5

Do not blame me about the method. I just doing practice and I woud like to reach the end. So, I'm storing via Javascript node.js some images into a remote mysql table using a blob field. Later I would like to retrieve the image and show it in a html5. I'm getting mad about the encode/decode proces. I stored the image using each of the following methods readAsDataURL(f); readAsBinaryString(f); readAsText(f); but when I retrieve the image I'm unable to diplay it in the image.src. The only way to do that is to load manually the image into blob field via phpmyadmin and later send the blob field to the html page using the following conversion:

var base64 = new Buffer(results[i].tile_image, 'binary').toString('base64');
client.emit('showTile', base64);

The question is: how does phpmyadmin load the binary files into a blob field? Or, using javascript how I have to load the image into a blob?

Converted comment into answer

Check out this tutorial on uploading images and storing them in MySQL.

To answer your question $imgData =addslashes (file_get_contents($_FILES['userfile']['tmp_name'])); can be broken down as such

$_FILES is an associative array of files uploaded to the document, in this case the image. [$_FILES]

files_get_contents reads the file into a string. In this case it will store the binary data of the file into a string which can be inserted into the DB.

addslashes escapes any characters that need to be escaped.