Count image views

前端 未结 6 1879
余生分开走
余生分开走 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:44

    Yes you're on a good start. I'd do something like this

     
    

    In image_counter.php, take $src = $_GET['src'] for image source.

    Then +1 the hit for that image in the database.

    Then do

    header('Content-type: image/jpeg');
    readfile($src);
    

提交回复
热议问题