title: How to use ACE editor to edit and save a file
body: <p>I'm a dummy in HTML.
  In my project, I want to use ACE editor to allow the user editing and saving a file.
  I succeed to load the file, and to open it with ACE editor.
  The problem is how to save it.
  For this part, I need your help.</p>
  
  <p>Here is the code I wrote to use ACE.</p>
  
  <pre><code>&lt;?php
  if(isset($_POST["save_modification"])){
  $file = "./".$_POST["file_name"];
  $file_ptr=fopen($file,"w");
  fwrite($file_ptr,$_POST["content"]);
  fclose($file_ptr);
  }?&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;link rel="stylesheet" media="all" type="text/css" href="./css/style.css" /&gt;
  &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div class="site"&gt;
      &lt;div class="header"&gt;
          &lt;span&gt;Test&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="clean"&gt;&lt;/div&gt;
  
  &lt;div class="corp"&gt;
      &lt;div class="corp_ctn"&gt;
          &lt;h1&gt;Edit a file&lt;/h1&gt;
  
          &lt;div id="content" class="paragraphe"&gt;
  
              &lt;?php
                  $dir=opendir("./");
                  while($file=readdir($dir)){
                      if(!in_array($file, array(".",".."))) {
                          echo '&lt;div style="float:left; margin:0 10px; text-align:center;"&gt;&lt;a href="?f='.$file.'"&gt;';
                          echo $file;
                          echo '&lt;/a&gt;&lt;/div&gt;';
                          echo '&lt;br/&gt;';
                      }
                  }
              ?&gt;
  
              &lt;br clear="all"/&gt;
  
              &lt;?php
                  if(isset($_GET["f"])) {
                      echo "&lt;h1&gt;{$_GET["f"]}&lt;/h1&gt;";
                      $file = "./".$_GET["f"];
                      $content = file_get_contents($file);
              ?&gt;
  
  
                      &lt;form method="POST" action="index_select_lua_script.php"&gt;
                          &lt;div id="editor" name="content" style="width:100%;height:200px;"&gt;
                              &lt;?php echo $content ?&gt; 
                          &lt;/div&gt;
  
                          &lt;script src="js/ace/ace.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
                          &lt;script&gt;
                              var editor = ace.edit("editor");
                              editor.setTheme("ace/theme/monokai");
                              editor.getSession().setMode("ace/mode/lua");
                              editor.getSession().setTabSize(4);
                              editor.setHighlightActiveLine(true);
                              editor.resize();
                          &lt;/script&gt;
                          &lt;input type="hidden" name="file_name" value="&lt;?php echo $_GET["f"] ?&gt;" /&gt;
                          &lt;input type="submit" name="save_modification" value="Save modification" /&gt;
                      &lt;/form&gt;
                      &lt;br/&gt;&lt;br/&gt;
              &lt;?php
                  }
              ?&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>When I save my modification, using the save button, the content is empty.
  Please, do you have an idea of how I can do it?</p>
  
  <p>Thank you</p>