dpb42021 2012-07-11 10:11
浏览 104
已采纳

在PNG中运行PHP

I just wondered..
I've seen that some pictures can have "arguments" in an url like this:

http://example.com/images/picture.png?width=120

But when I google it, I get instructions where the result would be like this:

http://example.com/images/picture.php?width=120
(with header("Content-type: image/png") and so on)

(How) can i make a piece of php-code run in a "picture"?

  • 写回答

5条回答 默认 最新

  • dongne1560 2012-07-11 10:14
    关注

    In fact nobody cares about the file extension, it's just a hint usually for desktop applications only on how to handle the file, when you just double click it. However, behind the URL is a normal script of whatever language, that returns the header Content-Type: image/png alongside with an image as binary.

    For example in PHP

    // do something
    header('Content-Type: image/png');
    readfile('/local/path/to/a/prepared/image.png');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了