php - CodeIgniter Captcha Image name

975

CodeIgniter Captchacreate_captcha($val) creates captcha and returns the image within theimg tag but is it possible to get only the image name?

Example

CI Captcha returns<img src='abc.jpg'>

What I requireabc.jpg only.

Thanks in advance.

204

Answer

Solution:

You can modify the imagename and set it as you want.

CodeIgniter/system/helpers/captcha_helper.php line 231

// change here. you can set your desired name here.
$img_name = $your_name.'.jpg';

You can modify it directly (probably not a good idea as updates may overwrite). Or you could create your own helper by copying the original, modifying and putting it in application/helpers.

So, copycaptcha_helper.php into application/helpers, make the changes on line 231, save, and you should be good.

295

Answer

Solution:

according to the manual

http://www.codeigniter.com/user_guide/helpers/captcha_helper.html?highlight=captcha#create_captcha

this function allways return the img tag, the only thing i think you can do is parse it using regular expressions ...

preg_match("/\w+='(\w+.\w+)'/", $input_line, $output_array);

References

http://php.net/manual/es/function.preg-match.php

http://www.phpliveregex.com/

People are also looking for solutions to the problem: php - Laravel: Transform JSON response data

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.