小编use*_*597的帖子

如何使用ACE编辑器编辑和保存文件

我是HTML的假人.在我的项目中,我想使用ACE编辑器来允许用户编辑和保存文件.我成功加载文件,并使用ACE编辑器打开它.问题是如何保存它.对于这部分,我需要你的帮助.

这是我写的使用ACE的代码.

<?php
if(isset($_POST["save_modification"])){
$file = "./".$_POST["file_name"];
$file_ptr=fopen($file,"w");
fwrite($file_ptr,$_POST["content"]);
fclose($file_ptr);
}?>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" media="all" type="text/css" href="./css/style.css" />
<title>Test</title>
</head>

<body>
<div class="site">
    <div class="header">
        <span>Test</span>
    </div>
</div>

<div class="clean"></div>

<div class="corp">
    <div class="corp_ctn">
        <h1>Edit a file</h1>

        <div id="content" class="paragraphe">

            <?php
                $dir=opendir("./");
                while($file=readdir($dir)){
                    if(!in_array($file, array(".",".."))) {
                        echo '<div style="float:left; margin:0 10px; text-align:center;"><a href="?f='.$file.'">';
                        echo $file;
                        echo '</a></div>';
                        echo '<br/>';
                    }
                }
            ?>

            <br clear="all"/>

            <?php
                if(isset($_GET["f"])) {
                    echo "<h1>{$_GET["f"]}</h1>";
                    $file = "./".$_GET["f"];
                    $content = …
Run Code Online (Sandbox Code Playgroud)

html javascript php ace-editor

6
推荐指数
1
解决办法
6174
查看次数

标签 统计

ace-editor ×1

html ×1

javascript ×1

php ×1