So I'm hosting a localhost website on my raspberry pi with Apache and I'm wondering how would I export a JSON string to a file onto the rpi. I know how to export a file but how would I send the file to the rpi so that I can see it on my file explorer. Right now all it does is make send the JSON to whoever is opening the page, but I need it to be sent to my rpi instead of whoever is opening up the webpage such as my phone or another computer on the network. I can use a web server as long as it's free, there wont be much traffic on the website, so any limitations should be alright. Here's my code for exporting to file:
function download(content, fileName, contentType){
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
and
download(JSON.stringify(data, null, 2), 'json.txt', 'text/plain');
I got this code from stackoverflow but I still haven't been able to find exactly what I'm looking for. PHP is fine but I don't really know how to use it, since I'm kind of a new coder. If I'm missing anything in my questions, comment so that I can fix it, because this is my first question.