包含目录中的文件并通过下拉列表加载到textarea中

Trying to reload files created back into textarea for re-editing.

Need to expand upon question asked at Saving file into new directory using fwrite

I have attempted to use info from Drop Down Select File And Include It into Same Page without success.

I can get the files listed from my /temp directory into dropdown, but cannot figure out how to reload them into text area.

Here is my complete PHP page:

<?php

    function saveFile($filename,$filecontent){
        if (strlen($filename)>0){
            $folderPath = 'temp';
            if (!file_exists($folderPath)) {
                mkdir($folderPath);
            }
            $file = @fopen($folderPath . DIRECTORY_SEPARATOR . $filename,"w");
            if ($file != false){
                fwrite($file,$filecontent);
                fclose($file);
                return 1;
            }
            return -2;
        }
        return -1;
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Save File Test</title>

   <link href="style/style.css" rel="stylesheet" type="text/css" />

</head>
<body>
    <div id="main">
          <div class="caption">Save File & Edit Test</div>


          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
            <table width="100%">
              <tr><td>File Name to Create: <input class="text" name="filename" type="text" size="40" value="test.ini" /></td></tr>
              <tr><td><br/>File Content: <textarea class="text" name="filecontent" rows="15" cols="146"></textarea></td></tr>
              <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Save File" /></td></tr>
            </table>  
          </form>

            <?php    
                if (isset($_POST['submitBtn'])){
                    $filename    = (isset($_POST['filename']))    ? $_POST['filename']    : '' ;
                    $filecontent = (isset($_POST['filecontent'])) ? $_POST['filecontent'] : '' ;
            ?>
              <div class="caption"></div>

         <div id="result">
            <table width="100%">

                <?php
                        if (saveFile($filename,$filecontent) == 1){
                            echo "<tr><td><br/>File was saved!<br/><br/></td></tr>";
                        } else if (saveFile($filename,$filecontent) == -2){
                            echo "<tr><td><br/>An error occured, most likely cause is file writing permissions!<br/><br/></td></tr>";
                        }
                ?>

            </table>
         </div>
        <?php } ?>


        <!-- My Dropdown Box at Bottom of Page -->

        <br/>
        Temp Folder Contents Load Into Textarea:
        <br />
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
        <select name="select" onChange="document.domain.submit()">
              <option value="" selected="selected">-----</option>
          <?php 
               foreach(glob(dirname(__FILE__) . '/temp/*') as $filename){
               $filename = basename($filename);
               echo "<option value='" . $filename . "'>".$filename."</option>";
                }
            ?>
        </select>
        </form>


    </div>
</body>
</html>

Since using multiple files from /temp directory, they should be populated into dropdown automatically.

Not sure at all about "foreach(glob(dirname(FILE) . '/temp/') as $filename)". Only way could get directory to list content was add the asterisk /

Like to use pure PHP (with little javascript) if at all possible. School firewall gets excited with jquery but will be happy to just get working either way.

Does not have to be a dropdown, just seemed the simplest and least space used.

Thanks in advance for assistance, need to complete for school project.