Hi, I have now a probleme in refreshing image; After displaying image in the form i have a little icon whene i click it call an ajax request to the same action (home/showCaptcha) for the goal to reload the captch with new caractere but the captcha refresh fail(in firebug i see the response it's a strange caractere) This the code i use to refresh the img (jQuery):
<script type="text/javascript"> $(document).bind('ready', function(){ $('#refresh_captcha').bind('click', function(){ $.ajax({ type: "POST", url: "<?php echo url_for('home/showCaptcha')?>", success: function(img){ $('#img_captcha').attr('src', img); } }); }); }); </script> Best regard Ahmed On 17 oct, 11:51, Ahmed <ghaliano2...@gmail.com> wrote: > Hi all i found the probleme > it's a php page encoded with utf8 (with BOM signature) (a filter used > in all the frontend app) > so the line break it's not visible. > i convert it to an utf8 without BOM with notepad++ and thecaptcha > work. > Thank you again. > On 13 oct, 17:27, Russen <nes...@gmail.com> wrote: > > > Yes, the magic string is definitely: > > > return $this->renderText('/myimage/url.jpg'); > > > or > > > return $this->renderText($imagecontent); > > > The use of that line will make Symfony forget about rendering any > > template, just like " return sfView::NONE; " would, but that the > > latter flushes any output as well. If you want to put something in a > > template, like outputting a file on disk, the template would look like > > this: > > > <?php readfile($path_to_file_on_disk); ?> > > > Cheers! > > > On Oct 12, 5:49 pm, Casey <casey.cam...@gmail.com> wrote: > > > > the imagejpeg() function echoes the image string, but text echoed in > > > actions seem to get thrown out in symfony (I don't know the exact > > > mechanism for this, but it seems to be the case). You need to call > > > $this->renderText(imagejpeg($image)) or something along those lines so > > > that the action actually sends the text output somewhere. Right now > > > there is nothing being output to the response. Thats why the function > > > works outside of symfony, but doesn't when you are working within > > > symfony. So your final method should look something like this: > > > > public function executeShowCaptcha(sfWebRequest $request) > > > { > > > $this->getResponse()->setContentType('image/jpeg'); > > > return $this->renderText(myTools::genCaptcha(uniqid > > > ())); > > > > } > > > > I haven't tried it, but I think it should work. > > > > HTH > > > --Casey > > > > On Oct 12, 5:45 am, Ahmed <ghaliano2...@gmail.com> wrote: > > > > > @Alexandre > > > > no change > > > > I have Always a 0x0 blanc image > > > > i search in all my project for a line break > > > > and i don't found any off them > > > > > @Vasos > > > > I try this trick > > > > > Cordialy > > > > Ahmed > > > > On 12 oct, 13:41, basos g <noxe...@gmail.com> wrote: > > > > > > 2009/10/12 Ahmed <ghaliano2...@gmail.com> > > > > > > > Hi all; > > > > > > I use symfony 1.2.9 > > > > > > I have a strange error in ouputing image with symfony , so i have a > > > > > > simple function to create image > > > > > > public static function genCaptcha($pass){ > > > > > > $image = ImageCreatetruecolor(100, 20); > > > > > > $clr_white = ImageColorAllocate($image, 255, 255, 255); > > > > > > $clr_black = ImageColorAllocate($image, 0, 0, 0); > > > > > > imagefill($image, 0, 0, $clr_black); > > > > > > > // *** Set the image height and width *** > > > > > > imagefontheight(15); > > > > > > imagefontwidth(15); > > > > > > > // *** Add the passcode in white to the image *** > > > > > > imagestring($image, 5, 30, 3, $pass, $clr_white); > > > > > > > // *** Throw in some lines to trick those cheeky bots! > > > > > > *** > > > > > > imageline($image, 5, 1, 50, 20, $clr_white); > > > > > > imageline($image, 60, 1, 96, 20, $clr_white); > > > > > > imageline($image, 5, 1, 100, 50, $clr_white); > > > > > > // *** Output the newly created image in jpeg format > > > > > > *** > > > > > > imagejpeg($image); > > > > > > > // *** Clear up some memory... *** > > > > > > imagedestroy($image); > > > > > > } > > > > > > > And in the action i write: > > > > > > public function executeShowCaptcha(sfWebRequest $request) > > > > > > { > > > > > > $response = $this->getResponse(); > > > > > > $response->setContentType('image/jpeg'); > > > > > > > myTools::genCaptcha(uniqid()); > > > > > > > $this->setLayout(false); > > > > > > > return sfView::NONE; > > > > > > } > > > > > > i use it in a template like this <img src="<?php echo url_for('home/ > > > > > > showCaptcha')?>" /> > > > > > > But i dont see any image in my template and whene i try to point it > > > > > > directly on the url like : > > > > > >http://127.0.0.1/test/frontend_dev.php/home/showCaptcha > > > > > > also i dont see the generated image > > > > > > For me it worked a code like this in the action: > > > > > > $response = $this->getResponse() ; > > > > > $response->setContentType('the contet type header'); > > > > > $response->setContent($image->asString()); > > > > > $response->send() ; > > > > > > But this supposes that you have the image as an object that supports > > > > > the > > > > > asString() method, whick returns the data as string instead of > > > > > outputing > > > > > them directly. > > > > > > One php method that returns string data is > > > > > file_get_contents('filepath') but > > > > > it reads from disk. Maybe you could find something that returns a > > > > > memory > > > > > image as string. Try setContent($image) as a speculation. If you find > > > > > the > > > > > solution say it here. > > > > > > Vasos --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---