How Can I Keeping Count of Downloaded Pictures?

J

Jofio

I am developing a picture gallery - pictures of landscapes and various
other subjects. My site has a left panel consisting of thumbnails of
pictures which when clicked displays the corresponding bigger picture
of it. Problem is I am trying to keep count of each and every picture
downloaded (saved to load computers by visitors). Is it within
javaScript realm o do that?

I thought of using onLoad event handler ... but not sure.

thanks

j9k22000
 
C

cwdjrxyz

Jofio said:
I am developing a picture gallery - pictures of landscapes and various
other subjects. My site has a left panel consisting of thumbnails of
pictures which when clicked displays the corresponding bigger picture
of it. Problem is I am trying to keep count of each and every picture
downloaded (saved to load computers by visitors). Is it within
javaScript realm o do that?

I thought of using onLoad event handler ... but not sure.

Perhaps someone else knows of a script solution, but this seems to be
something best done on the server. There are several server side
programs that keep very detailed records of all of the hits to your
site, including page counts for all types of pages, including images
and music. The host my domain is on provides the Webalizer program
installed, so you have to do nothing. You might have to install
Webalizer or some other like program on some servers, and some hosts
may not provide it or let you install it either.
 
R

Randy Webb

Jofio said the following on 2/15/2006 12:47 AM:
I am developing a picture gallery - pictures of landscapes and various
other subjects. My site has a left panel consisting of thumbnails of
pictures which when clicked displays the corresponding bigger picture
of it. Problem is I am trying to keep count of each and every picture
downloaded (saved to load computers by visitors). Is it within
javaScript realm o do that?

No. Just check your server logs.
I thought of using onLoad event handler ... but not sure.

And if .js is disabled? Or, I open the image in a new window via a
direct URL?
 
T

Thomas 'PointedEars' Lahn

Jofio said:
I am developing a picture gallery - pictures of landscapes and various
other subjects. My site has a left panel consisting of thumbnails of
pictures which when clicked displays the corresponding bigger picture
of it. Problem is I am trying to keep count of each and every picture
downloaded (saved to load computers by visitors). Is it within
javaScript realm o do that?

No, it is not. Images, like other Web resources, have to be downloaded
into the local cache or another buffer before they can be displayed/used
in the first place. Hence also the futile attempt of the uninitiated to
prevent images from being "stolen", by blocking browser functions. If the
image is not saved from the cache or the buffer, a screenshot suffices.
I thought of using onLoad event handler ... but not sure.

`onload' will definitely not help you here. It is called when the image
was fully loaded, not when it was saved as a non-temporary file.


PointedEars
 
T

Thomas 'PointedEars' Lahn

cwdjrxyz said:
Perhaps someone else knows of a script solution,

It depends on what you call a "script solution". There is no solution for
this with only client-side script in an unrestricted environment.
but this seems to be something best done on the server. There are several
server side programs that keep very detailed records of all of the hits to
your site, including page counts for all types of pages, including images
and music. [Webalizer]

A server-side application evaluating the server log files cannot distinguish
between image display, which requires download of image data first, or
image file download -- no URL modifications given, the request is exactly
the same. It also cannot know when data already downloaded is stored as a
file from a local buffer or a cache, which was the OP's requirement ("saved
to load to computers by visitors") -- that is something that needs to be
counted client-side.

The only way to count image _file_ downloads really is to provide for an
area where access to the image data requires a kind of login (may it be
automatically) on the Web site, and either serve the resource as inline
attachment only there (does not work in IE4 IIRC) or serve it with an
unrecognized media type, or use another client-side application that
registers a handler for the media type.

Compare Webshots.com who allow you to download up to 5 photos of lower
quality (800x600 instead of 16:9 or 1600x1200) a day with a free account
as application/x-webshots (suffix .wbz), but you need either the Webshots
application (Windows PC or Mac only) installed (which does the login
automatically before download) or you need to login on the Web site
yourself before this works, and for this you need to sign up before.
They use J(ava)Script generated server-side (pretty-printed here as best
as possible; a script that I would not recommend as is, though) to trigger
the respective CGI script, e.g.

function downloadPhoto(resolution)
{
document.cookie = "PopupReferer=" + escape(document.location.href)
+ "; path=/; domain=.webshots.com";
var args="&done=" + document.location.href
+ "&nextDisplayID=/tr/hr-sh/38583&tagExt=TopRated/HighestRated";
var url;
if (resolution == 'high')
{
url =
"http://www.webshots.com/scripts/PhotoDownload.fcgi?res=high&targetmode=&photos=39285";
}
else if (resolution == 'wide')
{
url =
"http://www.webshots.com/scripts/PhotoDownload.fcgi?res=wide&targetmode=&photos=39285";
}
else
{
url =
"http://www.webshots.com/scripts/PhotoDownload.fcgi?res=low&targetmode=&photos=39285";
}
url += args;

var version=0;
if (document.VersionDetector)
{
if (document.VersionDetector.GetWSVersion)
{
version = document.VersionDetector.GetWSVersion();
if (version > 0)
{
url += '&swver=' + version;
}
}
}

var hasClient = (version > 0)
|| (document.cookie.indexOf("redirect=") >= 0);
if (!hasClient
&& (navigator.appName.indexOf("Microsoft Internet Explorer") >= 0))
{
url += '&action=noClientForDownload';
}

document.location.href = url;
}

which retains download count for the user ID in a database, I presume
(rest assured that modifying the cookie does not allow you to cheat :)).


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top