Writing a JSON file in a specific file location

49 Views Asked by At

I currently have a program that takes in a bunch of input parameters and outputs values in a Json in the downloads file when I click on my save JSON file. This is the code that I have right now for my save Button:

saveBtn.addEventListener('click', function () {
            var data = getTableData();
            var jsonData = JSON.stringify(data, null, 2);

            var filename = 'data.json';
            var jsonBlob = new Blob([jsonData], { type: 'application/json' });

            var downloadLink = document.createElement('a');
            downloadLink.href = URL.createObjectURL(jsonBlob);
            downloadLink.download = filename;
            downloadLink.click();
        });

I'm trying to instead of automatically saving it to the downloads file, I want it to save to a specific folder. Is there any way I could do this using HTML and Javascript, and if so any help would be greatly appreciated, thank you!

0

There are 0 best solutions below