By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,220 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,220 IT Pros & Developers. It's quick & easy.

How Can I Keeping Count of Downloaded Pictures?

P: n/a
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

Feb 15 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Jofio wrote:
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.

Feb 15 '06 #2

P: n/a
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?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 15 '06 #3

P: n/a
Jofio wrote:
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
Feb 15 '06 #4

P: n/a
cwdjrxyz wrote:
Jofio wrote:
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,


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=392 85";
}
else if (resolution == 'wide')
{
url =
"http://www.webshots.com/scripts/PhotoDownload.fcgi?res=wide&targetmode=&photos=392 85";
}
else
{
url =
"http://www.webshots.com/scripts/PhotoDownload.fcgi?res=low&targetmode=&photos=3928 5";
}
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
Feb 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.