0

我想在桌面上的文本文件中检索 HTML 表单字段数据。

我有一个包含 HTML 表单字段框的 HTML 页面。

此外,我想运行一个将文本文件作为输入的 bash 脚本。bash 脚本包含以下命令:

 sed -f replacer input.txt > output.txt

我还必须将此output.txt文件包含在另一个 html 表单字段中。

帮帮我。谢谢你。

4

1 回答 1

0

有这样的html:

<form id="some" name="someName" method="post" action="/ur/url/to/post">
   <input type="text" id="some1" class="someClass" value="" name="fileWrite"/>
   <iput type="submit" value="submit" class="submitClass"/>
</form>

有一个这样的php脚本:

$myFile = "testFile.txt";
if(isset($_POST['fileWrite']) && !empty($_POST['fileWrite'])) {
      $fileWrite = $_POST['fileWrite'];
}
if($fileWrite) {
    $fh = fopen($myFile, 'a') or die("can't open file"); //Make sure you have permission
    fwrite($fh, $fileWrite);
    fclose($fh);
    exec('/your/command /dev/null 2>/dev/null &');
}

而已。工作完成。

于 2012-06-13T06:53:29.020 回答