Reputation: 21
I'm trying to use CKEditor to allow editing of a HTML file on my server. Below is the code I'm using. My thoughts with the PHP include function inside the CKEditor Textarea was that the user would be able to see what they are editing - therefore this would probably have to be set to an overwrite?
(Note: I have set the read/write permissions to the file on the server to 666)
<?php
$action = $_GET["action"];
$editor = $_POST["editor1"];
if($action = "save") {
$targetFolder = "/folder";
file_put_contents($targetFolder."file.html", $editor1);
}
?>
<form action="?action=save" name="myform" method="post" >
<textarea name="editor1" id="editor1" rows="20" cols="160">
<?php include($_SERVER['DOCUMENT_ROOT']. "/folder/file.html"); ?>
</textarea>
<script>
CKEDITOR.replace( 'editor1' );
</script>
<input type="submit" value="save">
</form>
Help would be very much appreciated. Thankyou.
Upvotes: 2
Views: 1419
Reputation: 4829
It's not 100% clear what it is you are needing help with - you don't say what doesn't work. I do notice that you are setting the variable "$editor" in
$editor = $_POST["editor1"];
but then attempting to write the file using "$editor1" in
file_put_contents($targetFolder."file.html", $editor1);
Upvotes: 1