-1

I have developed a HTML editor using codemirror. I am now searching for a way to let users save the code what is inside the div to the site's server, so they can view their site. I searched on the internet and found this on the internet:

<?php 
// Start the buffering // 
ob_start(); 
?> 
Your page content bla bla bla bla ... 
<?php 
echo '1'; 
// Get the content that is in the buffer and put it in your file // 
file_put_contents('yourpage.html', ob_get_contents()); 
?>

Source: Save current page as HTML to server

But now i am on a point: how can i save the content of the div into a html file on my server? I searched and found that on the line where it saids: "your page content bla bla bla bla" you have to use "", but it doesn't work. I am new to php so help is appreciated. Thanks in advance

Community
  • 1
  • 1
  • just so i can understand better ... you have an html editor ... and when you hit save you want the content of that editor to be stored as an html page ? where you visitors can open ? – Karim Magdy Mansour Jan 12 '15 at 14:27
  • it's hard to past code without understand the basic it works => file_put_contents('yourpage.html', ob_get_contents()); **yourpage.html** will be created on your server. this is the point i understand your question – donald123 Jan 12 '15 at 14:27
  • @KarimMagdyMansour Yes thats exactly what i mean! –  Jan 12 '15 at 14:30
  • Turn the input into a `
    ` input and `POST` it to your server on submit?
    – danhardman Jan 12 '15 at 14:31
  • 1
    Save everything as a string? – Waxi Jan 12 '15 at 14:31
  • Both thanks for the ideas, i didn't thought about that. I will look and try. THANKS! –  Jan 12 '15 at 14:33
  • what you do is pointless, however it will write the content to a file, it happens before user has any chance to edit, what you need to do is post request using ajax: http://stackoverflow.com/questions/9758738/save-content-of-a-div-to-new-file-with-jquery-ajax-and-php – neo Jan 12 '15 at 14:34
  • Wait, so you are going to let people create a html page, which will then be uploaded onto your server. I hope you are taking security seriously as allowing people you dont know to create content on your server might be a very bad idea – atmd Jan 12 '15 at 14:41

1 Answers1

0

use PHP Simple HTML DOM Parser read element of page by id, class & ...

Javad Khodadadi
  • 410
  • 1
  • 4
  • 13