Page 1 of 1

Image Error - Image Verification

Posted: Sat Jan 31, 2004 4:41 pm
by mattmcb
I received the following error:

Warning: imagepng(): Unable to open 'verify.jpg' for writing in /home/seekide/public_html/storegroup/sg_forum/venture.php on line 47

Here is the code...

Code: Select all

// Image Verification START
/*header*/ 
//Header("Content-Type: image/png"); 

/* initialize a session. */ 
session_start(); 

/*We'll set this variable later.*/ 
$new_string; 

/*register the session variable. */ 
session_register('new_string'); 

/*You will need these two lines below.*/ 
//echo "<html><head><title>Verification</title></head>"; 
//echo "<body>"; 
/* set up image, the first number is the width and the second is the height*/ 
$im = ImageCreate(200, 40);  

/*creates two variables to store color*/ 
$white = ImageColorAllocate($im, 255, 255, 255); 
$black = ImageColorAllocate($im, 0, 0, 0); 

/*random string generator.*/ 
/*The seed for the random number*/ 
srand((double)microtime()*1000000);  

/*Runs the string through the md5 function*/ 
$string = md5(rand(0,9999));  

/*creates the new string. */ 
$new_string = substr($string, 17, 5); 

 /*fill image with black*/ 
ImageFill($im, 0, 0, $black); 

 /*writes string */ 
ImageString($im, 4, 96, 19, $new_string, $white); 

/* output to browser*/ 
***LINE 47*** ImagePNG($im, "verify.jpg"); 
ImageDestroy($im);  
// Image Verification END
Can someone help?

Posted: Sat Jan 31, 2004 6:32 pm
by DuFF
Um, I think to output a .PNG the file has to be .PNG :idea:

Posted: Sat Jan 31, 2004 6:47 pm
by mattmcb
I get the same error even with that extension.