2

I can write text in the pdf file with using code at web site link

If user enter the xxx.com/sample.php .. link shows the manipulated pdf file in the php page.

To make a manipulation we need to call PHP page.

If user directly enter the xxx.com/SAMPLE.pdf .. link shows the original pdf file...

How can I write the PDF file, when the user directly call the .pdf extension?

Should I write special code in the httpdocs file ?

For Example; If user call .pdf extension from special directory like directory/SAMPLE.pdf execute the special function to process pdf file.

How do I solve this problem ?

I thank you for your interest in my question.

4

1 回答 1

3

我会使用 htaccess 将所有请求重定向到“folder/whatever.pdf”到“folder/pdfgenerator.php?file=whatever.pdf”。

这样,您可以在 PHP 中做任何您想做的事情,包括在显示文件之前生成文件或将其命名为“whatever.pdf”,您可以在我描述的示例中使用 $_GET["file"] 来获得它。

这里有一个类似的问题:mod_rewrite & .htaccess - redirect request for a file extension to a script

在您的情况下,它将类似于:

RewriteEngine On
RewriteRule (.+\.pdf)$ /pdfgenerator.php?file=$1 [NC,L]
于 2013-04-22T10:11:50.633 回答