Count image views

前端 未结 6 1881
余生分开走
余生分开走 2021-01-25 08:14

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 hav

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 08:46

    Your script needs to:

    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 ) );

    For examples, please see the readfile documentation and Output an Image in PHP.

提交回复
热议问题