【发布时间】:2012-02-24 02:35:03
【问题描述】:
我们的网站即时创建文件,将用户指定的数据呈现给网络上的世界。
在每个这样的“_present.php”文件中都有一个需要发布到自身的表单——唯一的问题是,文件是根据上传的用户数据动态创建的,而且文件名也有些随意。
流程如下
1) a 'standard' file called _present.php has a common form "TheForm" in it
2) this file, _present.php, is copied to Yf9iZ17a.php (for example) when
the user uploads data -- and from that point, Yf9iZ17a.php presents
that user's just-uploaded data
3) and "TheForm" is inside this Yf9iZ17a.php, which again is just a copy of
_present.php, but modified to handle the user's just-uploaded data
很简单。 _present.php 里面有“TheForm”;用户上传他们的数据;我们将 _present.php 复制到 该用户数据的文件名。
问题是——我们需要 TheForm 发布到它自己的 文件名,它是动态创建的。
换句话说,这还不够:
<form name="TheForm" method="post" action="_present.php">
但是,这会起作用:
<form name="TheForm" method="post" action="Yf9iZ17a.php">
但我们不能用“Yf9iZ17a.php”对表单的 html 进行硬编码,因为 -- 该文件名是创建的 动态、即时、运行时。
这是我们成功执行的一次失败:
<form name="TheForm" method="post" action="<?php echo __FILE__ ; ?>">
“查看页面源代码”确实证明“php echo FILE”正确地回显了 Yf9iZ17a.php 的完整路径(不是相对路径,完整路径)。
那行不通。为浏览器提供文件的完全限定路径名—— 在服务器上的文件 -- 那么你为什么要首先这样做,除非 你在抓稻草。所以这是失败的。
这肯定会出现,动态创建的文件名,其内部形式必须发布到这些文件名—— 解决这个问题的最佳方法是什么?
【问题讨论】:
标签: php forms dynamic-data