0
$.post("save-file.php",{text:txt},function(data){
                                        if (data.length>0) { 
                                            $("#out").html('');
                                            fetch(data)
                                                .then(resp => resp.blob())
                                                .then(blob => {
                                                    const url = window.URL.createObjectURL(blob);
                                                    const a = document.createElement('a');
                                                    a.style.display = 'none';
                                                    a.href = url;
                                                    // the filename you want
                                                    a.download = 'synonymizer-su-file-<?php echo date('YmdHis')?>.doc';
                                                    document.body.appendChild(a);
                                                    a.click();
                                                    window.URL.revokeObjectURL(url);
                                                })

I tried to insert the function into the code somehow, but it didn't work out:

let reader = new FileReader();
reader.readAsDataURL(blob);
OMi Shah
  • 5,768
  • 3
  • 25
  • 34
Aleks
  • 11
  • 1

0 Answers0