you can make a script in PHP that you will send the JSON data with the POST in AJAX, and a script in PHP that take the value and build the file .json where you want in the server...
try to find on internet "make .txt/json file in php"
this works for me very well, I don't know if there is a method to upload directly the file, I mean, save on the cache and after send the file to a specific folder, but I think is more safe with the first method