title: Saving tinymce textarea content to file
body: <p>I have been trying to save tinymce editor textarea content to a .txt file for a while but without success yet.
  This is my html file code:</p>
  
  <pre><code>&lt;!Doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;TinyMCE example&lt;/title&gt;
    &lt;meta name="description" content="HTML5 Basic template"&gt;
    &lt;meta name="author" content="R Dickinson"&gt;
    &lt;link rel="stylesheet" href="css/styles.css?v=1.0"&gt;
    &lt;script src="js/scripts.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
  tinyMCE.init({
  // General options
  mode : "textareas",
  
  });
  &lt;/script&gt;
    &lt;!--[if lt IE 9]&gt;
    &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
    &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;header&gt;
  &lt;h1&gt;test tinymce save&lt;/h1&gt;
      &lt;/header&gt;
      &lt;nav&gt;
      &lt;/nav&gt;
      &lt;section&gt;
  
  &lt;form method="post" action="test.php"&gt;
      &lt;p&gt; 
          &lt;textarea name="content" style="width:50%"&gt;&lt;/textarea&gt;
          &lt;input type="submit" value="Save" /&gt;
      &lt;/p&gt;     
  &lt;/form&gt;
      &lt;/section&gt;
      &lt;aside&gt;
      &lt;/aside&gt;
      &lt;footer&gt;
          &lt;/footer&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now test.php</p>
  
  <pre><code>&lt;?php
  /*
   * test.php
    */
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  
  &lt;head&gt;
      &lt;title&gt;test tiny mce&lt;/title&gt;
      &lt;meta http-equiv="content-type" content="text/html;charset=utf-8" /&gt;
      &lt;meta name="generator" content="Geany 0.21" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  
  echo(stripslashes($_POST['content']));
  ?&gt;
  &lt;?php
  $file = "data.txt";
  $fp = fopen($file, 'w');
  $data =(stripslashes($_POST['content']));
  fwrite($fp, $data);
  fclose($fp);
  ?&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm grateful for helpful replies to fix this-many thanks :-)</p>
  
  <p><strong>Update</strong>
  Following the first answer below I have added triggerSave as:</p>
  
  <pre><code> &lt;script language="Javascript"&gt;
  function submitForm() {
  tinyMCE.triggerSave();
  document.forms[0].submit();
  }
  &lt;/script&gt;  
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;form method="post" action="test.php"&gt;
  &lt;p&gt; 
      &lt;textarea name="content" style="width:50%"&gt;&lt;/textarea&gt;
      &lt;!--&lt;input type="submit" value="Save" /&gt;--&gt;
      &lt;a href="javascript:submitForm();"&gt;Submit Form&lt;/a&gt;
  &lt;/p&gt;     
  </code></pre>
  
  <p></p>
  
  <p>but still no success...More help gratefully received</p>
  
  <p><strong>UPDATE 2</strong>
  Here is my jQuery TinyMCE version:</p>
  
  <pre><code> &lt;!Doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Sample WebPage&lt;/title&gt;
    &lt;meta name="description" content="HTML5 Basic template"&gt;
    &lt;meta name="author" content="R Dickinson-see sitepoint etc"&gt;
    &lt;link rel="stylesheet" href="css/styles.css?v=1.0"&gt;
    &lt;script src="js/scripts.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
          google.load("jquery", "1.3");
  &lt;/script&gt;
  &lt;!-- Load jQuery build --&gt;
  &lt;script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  tinyMCE.init({
          mode : "textareas"
  });
  &lt;/script&gt;
    &lt;!--[if lt IE 9]&gt;
    &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
    &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;header&gt;
          &lt;h1&gt;Enter the main heading, usually the same as the title.&lt;/h1&gt;
      &lt;/header&gt;
      &lt;nav&gt;
      &lt;/nav&gt;
      &lt;section&gt;
  
  
  &lt;!-- OF COURSE YOU NEED TO ADAPT ACTION TO WHAT PAGE YOU WANT TO LOAD WHEN HITTING "SAVE" --&gt;
  &lt;form method="post" action="show.php"&gt;
          &lt;p&gt;     
                  &lt;textarea name="content" cols="50" rows="15"&gt;This is some content that will be editable with TinyMCE.&lt;/textarea&gt;
                  &lt;input type="submit" value="Save" /&gt;
          &lt;/p&gt;
  &lt;/form&gt;
  
      &lt;/section&gt;
      &lt;aside&gt;
      &lt;/aside&gt;
      &lt;footer&gt;
  
    &lt;/footer&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>