質問

Hey guys I was wondering if it's possible to get the content within the tags I have using PHP. I'm using the Ace editor and I have a save button. I'm trying to save the content to a file using PHP, can someone tell me how I can get the content using PHP please?

役に立ちましたか?

解決

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';
    }

?>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top