PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
file_put_contents(.png) [function.file-put-contents]:

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Text
View previous topic :: View next topic  
Author Message
aman@pear



Joined: 16 Aug 2008
Posts: 1

PostPosted: Fri Oct 03, 2008 8:56 am    Post subject: file_put_contents(.png) [function.file-put-contents]: Reply with quote

file_put_contents(.png) [function.file-put-contents]: failed to open stream

This is the error coming when i am running a script like


require_once 'Text/CAPTCHA.php';
require_once 'Image/Text.php';

// Set CAPTCHA options (font must exist!)
$imageOptions = array(
'font_size' => 24,
'font_path' => './',
'font_file' => 'arial.TTF',
'text_color' => '#DDFF99',
'lines_color' => '#CCEEDD',
'background_color' => '#555555'
);

// Set CAPTCHA options
$options = array(
'width' => 200,
'height' => 80,
'output' => 'png',
'imageOptions' => $imageOptions
);

// Generate a new Text_CAPTCHA object, Image driver
$c = Text_CAPTCHA::factory('Image');
$retval = $c->init($options);
if (PEAR::isError($retval)) {
printf('Error initializing CAPTCHA: %s!',
$retval->getMessage());
exit;
}

// Get CAPTCHA secret passphrase
$_SESSION['phrase'] = $c->getPhrase();

// Get CAPTCHA image (as PNG)
$png = $c->getCAPTCHAAsPNG();
if (PEAR::isError($png)) {
echo 'Error generating CAPTCHA!';
echo $png->getMessage();
exit;
}
file_put_contents((session_id()) . '.png', $png);
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1000

PostPosted: Fri Oct 03, 2008 4:07 pm    Post subject: Re: file_put_contents(.png) [function.file-put-contents]: Reply with quote

aman@pear wrote:
file_put_contents(.png) [function.file-put-contents]: failed to open stream
[...]
file_put_contents((session_id()) . '.png', $png);


Not really a question that is related to PEAR ...

It helps to read the PHP manual:
Quote:

Return Values

session_id() returns the session id for the current session or the empty string ("") if there is no current session (no current session id exists).

http://www.php.net/manual/en/function.session-id.php
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Text All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software