How to change qr code filename while downloading the file using html.twig and javascript

I have a qr-code button. On click, qr-code is generated and dialog to save the image format pops-up. In which the filename always comes as “qrcode.png”. I have to dynamically change the filename to the name of the files from where the qr-code is generated.

Please, help. I am new to this technology.


<th data-field="QR-BTN" data-width="60px" data-orderable="false">{{ 'QR'|trans }}</th>


var QREXPORT = (function() {

var qrCodeExport = function (e){

    // api url 
    const QRCODE_API_URL = ""; //Library Used

    var $form            = $('#modal-qr-export-offering'),
        qrFormat         = $("input[name='qrCodeType']:checked").val(),
        jsFormData       = $'bs.modal'),
        accessCode       = jsFormData.options.accesscode;

    var params = {
                    data:     "SESSION-" + accessCode,
                    size:     "250x250",
                    margin:   0,
                    download: 1,
                    format:   qrFormat,

    window.location.href = QRCODE_API_URL + $.param(params); 


return {

    init: function() {


            $('#radioSvg').prop('checked', true);

            $('#modal-qr-export-offering').on('', function() {


        $(document).on('click', '.js-btn-submit-form', qrCodeExport);




Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *