Re: How Can I Keeping Count of Downloaded Pictures?



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=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
.



Relevant Pages

  • Smart File Downloader - simple script on xampp
    ... and i need to apply simple script from this link. ... i use xampp 1.7.7 in windows 2000 server with public IP ... // Allow direct file download? ... // get mime type ...
    (comp.lang.php)
  • Re: Error When Removing AD from BDC
    ... downloaded it and saved the script in the folder specified. ... > you should move any fsmo roles off of this server. ... > tools if not loaded can be installed from the server install cd). ... > If you download a gui script I wrote it should be simple to set and run. ...
    (microsoft.public.win2000.active_directory)
  • imapget: an IMAP mail download and filter script
    ... I've cleaned up a perl script that I use to download ... can connect to server via SSL ...
    (Debian-User)
  • Re: IE Wont Open
    ... How to disable script and runtime errors ... You can get the Sun Java J2SE RunTimes or SDK here: ... Sun also offers an automatic download and install of the 1.4 Java plug-in ... Under the server column, for trusted, change that to a check. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Download program
    ... picture - you're telling me it's completely impossible, ... cooperation, right? ... >>way of building a program that will access the URL of a download and then ... not just programs served by a particular server ...
    (microsoft.public.dotnet.languages.csharp)