I want to know if this image has been viewed

let say if I have this link : www.example.com/image.jpg

when the imaged get viewed I want store the time of view in db , my only problem is how can I tell if the image has been viewed and how to go about trigging the storeInfo() function

Thanks!

Recommended Answers

All 4 Replies

you could use mod_rewrite to have that url redirected to something like images.php?file=image.jpg and then you can update the database in that script using the file name in the url.

do what keith says, or; before the person goes onto the image, put them onto an page that uses a GET parameter to remember what image needs to be logged. It will get the image name, date and time and insert it into the database. Then it will redirect to the image page using the GET parameter.

Apache already logs the access to your image (image view)

All you have to do is configure apache to log access to certain files (like images) to a database instead of to the normal access log.

If you have control over your server, then install something like mod_log_sql and configure it accordingly.

I've done exactly that for my image site, I can post instructions if you need.

Thank guys so much
unfortunately I don't have control over the server but I found another way just maybe some wanna know

I created a folder with the image name
and inside the folder I have index.php which will log the information I need and view the image to the visitor

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.