Save file with dynamic data and file prompt

How can I obtain a file-save prompt in order to SAVE dynamic data?

I tried with JQuery:

$(‘download’, {
“download”: exportFileName,
“href”: “data:,” + encodeURIComponent(stringa2),
“id”: “exportDataID”

BUT don’t prompt anything

Then I tried with classic Javascript:

// grab the content of the form field and place it into a variable
var textToWrite = stringa2;
// create a new Blob (html5 magic) that conatins the data from your form feild
var textFileAsBlob = new Blob([textToWrite], {type:‘text/plain’});
// Specify the name of the file to be saved
var fileNameToSaveAs = “myNewFile.txt”;

// Optionally allow the user to choose a file name by providing
// an imput field in the HTML and using the collected data here
// var fileNameToSaveAs = txtFileName.text;

// create a link for our script to 'click’
var downloadLink = document.createElement(“a”);
// supply the name of the file (from the var above).
// you could create the name here but using a var
// allows more flexability later. = fileNameToSaveAs;
// provide text for the link. This will be hidden so you
// can actually use anything you want.
downloadLink.innerHTML = “My Hidden Link”;

// allow our code to work in webkit & Gecko based browsers
// without the need for a if / else block.
window.URL = window.URL || window.webkitURL;

// Create the link Object.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
// when link is clicked call a function to remove it from
// the DOM in case user wants to save a second file.
//downloadLink.onclick = destroyClickedElement;
// make sure the link is hidden. = “none”;
// add the link to the DOM

// click the new link;

BUT internal BROWSER show an error concerning “permission”

If I don’t compile html it works, but NOT compiled.

Any ideas?

Take a look at:

Instead of using OpenFileDialog, use SaveFileDialog as explained here:

Thus, you’ll get a way to display a “Save As” file prompt.
Then you get the full path to the file the user wants to save data to, and you use PHP code to write data.