Image encoding

I’m inserting an encoding image in database. Image is encoding in base64 but it is not inserting If I manually add it in browser with same code of image that time it is inserting successfully
I’m converting my image using following code

window.plugins.Base64.encodeFile(imageData, function (base64) {

            imageData = base64;
            window.localStorage.setItem("imgURI", imageData);


Here imageData is FILE_URI which I’m selecting from gallery