Page 1 of 1

Possibility to save a file as download

Posted: Thu Dec 31, 2015 7:08 am
by Stefan Schnell
Hello Fred,

a suggestion for a future release, is a function to save a file as download. Here my example for a binary database file:

Code: Select all


  ; Sub btnSaveEvent----------------------------------------------------
    Procedure btnSaveDBEvent()

      ; Variables-------------------------------------------------------
        Protected b64enc.i, link.i

      !v_b64enc = btoa(String.fromCharCode.apply(null, v_dbase.export()));
      !v_link = document.createElement("a");
      !v_link.setAttribute("href", "data:application/octet-stream;base64," + v_b64enc);
      !v_link.setAttribute("download", "test.sqlite");
      !v_link.click();

    EndProcedure

Thanks in advance.

Cheers
Stefan