May you can save it via AJAX, send the editor content and desired filename (and path also) using POST method
example
function saveCode () {
$.ajax({
url: 'handler.php',
type: 'POST',
dataType: 'html',
data: {code: editor.getValue(), filename: './test.php'},
})
.done(function(result) {
console.log("success");
});
}
then on the handler.php
<?php
if(isset($_POST['code']))
{
file_put_contents($_POST['filename'], $_POST['code']);
echo 'success';
}
?>