计算图像视图 [英] Count image views

查看:112
本文介绍了计算图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个图像代码来计算图像的查看次数,无论图像在哪个站点上找到。我想使用img src标签,并让src指向一个计算该视图的php页面,然后返回要查看的图像。我在想这样的事情:

I would like to have code for an image that counts the number of times the image is viewed, regardless of what site the image is found on. I want to use the img src tag, and have src point to a php page that counts that view and then returns the image to be viewed. I was thinking something like this:

 <img src="www.mywebsiteurl.com/something.php" /> 

如何编写something.php以便返回正确的图像文件?我知道如何记录页面视图,但如果我必须在这种情况下做一些不同的事情,请告诉我。

How would I go about writing "something.php" so that it returns the proper image file? I know how to record the page view, but if I must do something different in this case, please tell me.

推荐答案

你的脚本需要:


  1. 记录命中。

  2. 设置输出的内容类型( header('Content-Type:image / jpeg');

  3. 输出图像( readfile($ path_to_image));

  1. Record the hit.
  2. Set the content type of the output ( header('Content-Type: image/jpeg'); )
  3. Output the image ( readfile( $path_to_image ) );

例如,请参阅 readfile文档用PHP输出图像

这篇关于计算图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆