0

我有这个 php 文件名为:pdf5.php

在该文件中,我有以下几行:

$pdf->setSourceFile('h.pdf'); 

我希望能够使用代码或脚本编辑这些行“h.pdf” 。


问题是我想这样做:

我有另一个名为 editpdf.php 的 php 文档

使用这些输入

<input type="text" value="h.pdf" /> <br>
<input type="text" value="" /> - Lets say the user puts: **f.pdf**
<input type="submit" name="submit" value="Modify" />

并且当用户单击修改时,-pdf5.php- 中的 -h.pdf- 更改为 -f.pdf-

像这样:$pdf->setSourceFile('f.pdf');


我想我发现了类似的东西,但它只编辑同一个页面,它不允许用户修改它。

JavaScript 替换()

  <script type="text/javascript">
  var str="Visit Microsoft!";
  document.write(str.replace("Microsoft", "hello"));

所以有什么想法???我不知道我是否让自己足够清楚......??thnx 在高级..

4

2 回答 2

0

如果我正确地回答了您的问题,您需要修改一个 PHP 变量。为此,您可以通过表单或AJAX GET/POST 到该页面

在 HTML 中

<form method="GET" action="">
    <input type="text" name="old" value="h.pdf" /> <br>
    <input type="text" name="new" value="" /> <br/>
    <input type="submit" name="submit" value="Modify" />
</form>

在 PHP 中:


//...Use the foll. way
if (file_exists($_GET['new']))
    $pdf->setSourceFile($_GET['new']);
else
    echo "ERROR! No file found!";
//...
于 2011-01-23T17:15:09.817 回答
0

您必须发送您的表单(最好使用POST)并使用该 POST 变量作为参数$pdf->setSourceFile,例如:

<form method="POST" action="…">
   <input type="text" name="old" value="h.pdf" /> <br>
   <input type="text" name="new" value="" />
   <input type="submit" name="submit" value="Modify" />
</form>

和 PHP:

$newvalue = $_POST['new']; // but: always do some sanity checks!!!
$pdf->setSourceFile($newvalue);

正如已经说过的:在将它们提供给函数之前,始终检查您从用户那里收到的输入值(例如,使用哈希表) !

于 2011-01-23T17:07:23.590 回答