如何在 png/jpg 扩展名中运行 php 脚本 [英] How to run php script in png/jpg extension
问题描述
我如何编辑 .htaccess 文件以使客户端运行 php 脚本,但使用 png/jpg 扩展名.苏...用户将访问 url
How can i edit .htaccess file to make client run php script, but in png/jpg extension. Soo... User will visit url
http://example.com/script.png 他会看到test"(php脚本将返回此值),而不是图像.这就是我已经做的:.htaccess 文件:
http://example.com/script.png and he will see "test"(php script will return this value), not image. That's what i already did: .htaccess file:
AddType application/x-httpd-php .png
script.png 文件:
script.png file:
<?php
header("Content-type: image/png");
echo 'test';
?>
这段代码有什么问题?为什么它不起作用?浏览器尝试下载图像:/
What is wrong with this code? Why it doesn't work? Browser tries to download the image :/
推荐答案
将以下行添加到您的 .htaccess
文件
Add the following line to your .htaccess
file
AddHandler application/x-httpd-php .png
这告诉服务器将所有以 .png
结尾的文件处理为 .php
.
This tells the server to process all files ending with .png
as .php
.
这篇关于如何在 png/jpg 扩展名中运行 php 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!