image download verification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

image download verification

Post 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! :banghead:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: image download verification

Post by onion2k »

Ask the user? Give them a button that says "Click here if the image downloaded".
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Re: image download verification

Post by toasty2 »

Not a PHP solution, but you could use some Javascript and do some checks client-side.
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

Re: image download verification

Post 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.
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

Re: image download verification

Post 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?
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

Re: image download verification

Post 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

Code: Select all

 
if($_COOKIE['imgchk']){
//code
}
 
desius
Forum Newbie
Posts: 9
Joined: Thu Apr 17, 2008 1:38 pm

Re: image download verification

Post 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! :cry:

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.
Post Reply