tracking file downloads<

liunx

Guest
say i have a bunch of pictures on hosting machine
(where my site located) and user who browses my site
enters exact url for my picture "nice.jpg" something like:
<!-- m --><a class="postlink" href="http://www.myhost.com/~mysite/pics/nice.jpg">http://www.myhost.com/~mysite/pics/nice.jpg</a><!-- m -->

and he starts to Download this picture...

Is there a way for my script to be aware of this Download ?
For example if i wanna keep a count number of Download s for each picture then if the user clicks on the link on my page,
the browser will send the request to host, which in turn will call my script... but what about the case i described above(entering direct address for picture)you cant keep track if its from the actual .jpg file. you could have a php file that reads the image and outputs it with an image header, which keeps track of the number of views. but you cant track it if he starts to Download it from the exact address.maybe there is some way to ask the server to call my hook function upon certain events?again, theres no way to do it with php, unless you store all real images in a directory above the public_html one so no one can view it. and then you could use mod_rewrite to link to what looks like a real file name but calls the php script and gets the specified image from the directory and outputs it. that way, they cant get around the php script being called. when the right click and downlaod an image, as far as i know, its just getting it from their system cache.

you could probably set up some sort of shell script or something that does something when they view the actual image but i dont have any idea how to do any of that.i can ask my host to forbid any direct access to any of my site folders... this can help?

also.. i don't care if someone will Download the image i simly wanted to understand how can i track number of Download s

finaly from what your answer i got the impression(mod_rewrite) that you thinking that i'm host owner...
well i'm not.... i just wanna biuld homepagemost hosts let you have access to the directory above public_html, at least all the ones that ive gone to have. you would just have to set the directory where images are stored to where people browsing from their browser cant view it, but the script can.
but like i said, you cant track if they actually save the image, because theyve already Download ed it to their cache, so when they save it it just copies the image from the cache. you can only track how many views its had.you could have a script that scan thru the web server log file to count how many time the file as been accessed.well, if i can know number of views that enough for me:)

thankseww that is a,lot of work. writing a script to scan the log file? you have to know what to look for exactly.

I would keep the image folder right were it is at. make a script and use readfile() and then nobody can see where it is coming from. but it really is best to stop them from entering any image in that folder is if they are a member or something. if they are not a member then why worry about it?

you can use mod_rewrite even if you are not own of the server. you can call it by a file called htaccess.
 
Back
Top