php - CodeIgniter Captcha Image name


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


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

What I requireabc.jpg only.

Thanks in advance.




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.




according to the manual

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);


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


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.