我可以使用 header() 传递查询字符串参数吗?
我在 Windows 上使用 XAMPP。
我已将 Apache 配置为将所有请求重定向到controller.php 文件。控制器在进行任何其他处理之前将所有请求记录到数据库,并且还执行其他一些操作,包括检查访问所涉及文件的权限。
大多数请求映射到一个文件,然后我使用适当的标头和读取文件来提供该文件。例如:
header ( 'Content-Type: text/css' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );
我的问题是,如果 URL 包含查询字符串,我不知道如何将其传递到文件。
http:///myswf.swf?q1=test 映射到 C:\SWF\myswf.swf
header ( 'Content-Type: applicaton/x-shockwave-flash' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );
无法将 q1 参数传递给 SWF。
我无法修改 SWF。
我应该如何调用 SWF 并从 PHP 中成功传递参数?
I'm using XAMPP on Windows.
I've congigured Apache to redirect all requests to a controller.php file. The controller logs all requests to the database before any other processing takes place and it does a few other things too including checking permission to access the files involved.
Most requests map to a file which I then serve with appropriate headers and a readfile. For example:
header ( 'Content-Type: text/css' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );
My problem is that if the URL contains a query string I don't know how to pass that to the file.
http:///myswf.swf?q1=test maps to C:\SWF\myswf.swf
header ( 'Content-Type: applicaton/x-shockwave-flash' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );
fails to pass the q1 parameter to the SWF.
I can't tinker with the SWF.
How should I call the SWF and successfully pass the parameters from within PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SWF 文件不在服务器上执行。因此,您无法将任何内容“传递”到 SWF 文件。该文件只需由客户端下载,然后在浏览器中运行,即可获取 URL 参数。从客户端来看,这看起来像这样(简化):
只要该过程在客户端像这样工作,那么您的服务方式并不重要文件。
The SWF file is not executed on the server. As such, you cannot "pass" anything to the SWF file. The file is simply downloaded by the client and then run in the browser, which is were it will get the URL parameters. From the client side, this looks like this (simplified):
As long as the process works like this on the client side, it doesn't matter how exactly you serve the file.
据我了解,您不能在文件名中使用 GET 参数,因此 readfile(filename.php?q=123);不会传递参数,
事实上我认为唯一可以做到这一点的方法是使用远程 file_get_contents();例如:
在这种情况下,domain.com 上的网络服务器将处理 swf 文件的参数,这意味着虽然 SWF 文件需要可公开访问,但没有人会知道它所在的位置,因此您可以像
domain.com/asfqwasc213412sad/file.swf
这样的文件夹来掩盖它我对 SWF 如何处理 GET 参数不太有经验,所以这都是关于服务的假设带有参数
更新 的 SWF 文件
感谢 @deceze 提供此信息,由于参数的工作方式,这可能不适用于 SWF 文件
As far as i understand it, you cannot use GET parameters in a filename, so readfile(filename.php?q=123); will NOT pass parameters,
In fact i think the only way you could do this is with a remote file_get_contents(); suchas:
In that case, the webserver at domain.com will handle the parameters to the swf file, this means though that the SWF file will need to be publically accessible, but no-one will figure where it is located, so you could have a folder like
domain.com/asfqwasc213412sad/file.swf
to obscure itIm not too experienced on how SWF handles GET params, so this is all assumption in terms of serving the SWF file with the params
Update
Thank you @deceze for this info, this probably won't work on SWF files because of the way the params work