1

How to get base64 of the files uploaded by Blueimp Jquery File Upload?

I want to do something like this:

$('#fileupload').fileupload({
    url: uploadUrl,
    dataType: 'json',
    add: function (e, data) {
        console.log(data.files[0].getBase64());

Is it possible?

Thanks!

viniciuswebdev
  • 1,286
  • 1
  • 11
  • 20
  • fwiw https://stackoverflow.com/questions/50729816/jquery-file-upload-plugin-https-blueimp-net/50730074?noredirect=1#comment88467916_50730074 – ficuscr Jun 06 '18 at 21:59

1 Answers1

0

I was looking for the exact same thing and I've ended up doing this. Maybe it helps someone else

$("#fileupload").fileupload({
    change: function(e, data)
    {
        var reader = new FileReader();

        reader.onload = function(e)
        {
            var base64 = this.result;

            console.log(base64);

            //$("image_selector").attr("src", base64);
        }

        $.each(data.files, function(index, file)
        {
            reader.readAsDataURL(file);
        });              
    }
});
Matías Cánepa
  • 5,770
  • 4
  • 57
  • 97