Page 1 of 1
image download verification
Posted: Thu Apr 17, 2008 4:20 pm
by desius
is there another way in php to verify that an image has downloaded other than calling a script like:
<img src="myPhpScript.php height="1" width="1" />
please help!

Re: image download verification
Posted: Thu Apr 17, 2008 4:55 pm
by onion2k
Ask the user? Give them a button that says "Click here if the image downloaded".
Re: image download verification
Posted: Thu Apr 17, 2008 10:09 pm
by toasty2
Not a PHP solution, but you could use some Javascript and do some checks client-side.
Re: image download verification
Posted: Fri Apr 18, 2008 1:00 pm
by desius
toasty2 wrote:Not a PHP solution, but you could use some Javascript and do some checks client-side.
Kay' How might I pass that check into php?

I'm somewhat of a newb on some things like this.
Re: image download verification
Posted: Fri Apr 18, 2008 1:38 pm
by desius
wait, I think I know how I'll go about it using your suggestion, let me know your thoughts on this.
I'll use <img src="myJavaScript.js" height=1 width=1 />
and in the script, I'll set a cookie and use php to check and make sure that cookie exists. That'd bring both cookie testing, javascript testing, and image testing that could filter out most bots. Good idea to do it this way or not?
Re: image download verification
Posted: Fri Apr 18, 2008 2:38 pm
by desius

Having trouble grabbing the cookie my javascript is setting in php. php doesn't seem to be recognizing the cookie that the javascript is setting. is this right?
imgcheck.js
Code: Select all
setCookie("imgchk", imgchk, 0);
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
and in my html theres
Code: Select all
<img src="pathToJsFile/imgchk.js" height="1" width="1" />
and in the php i check for the cookie with
Re: image download verification
Posted: Fri Apr 18, 2008 3:40 pm
by desius
looks like the javascript isn't even creating the cookie. Obviously, it's either not getting called, or somethings wrong with the imgchk.js code, Any ideas anyone? please helpe!
EDIT: Yeah, tested it. It's the javascript not getting called. Can I not call a script this way? Everything I've read says yes, but I've never done it.