Can anyone help me out with a PHP code that will count how many times an image has been viewed?
I need more of a webstats kind of code, not a code that goes on a page with the image.
I want to be able to see how many times /imagex.gif has been loaded into someone's browser.
Any suggestions?
Load Image Counter?
Moderator: General Moderators
this would be extremely basic
use this in the html
use this in the html
Code: Select all
<img src="counter.php">Code: Select all
<?php
$views = file_get_contents('views.log'); // get current views
$views++; // add 1
// log new count
$fp = fopen('views.log', 'w');
fwrite($fp, $views);
fclose($fp);
header('Content-type: image/gif'); // send mime header
readfile('blank.gif'); // output an image
?>