hoseng
(Shahsahebih)
June 8, 2014, 7:25am
1
Hello Dears;
I’m asking this question after searching.
For some reason I want to create my own captcha, I create it’s php file and place it in images folder with name ‘captcha.php’, but when I want to include and test it I got that error. could you help me to solve this. My OS is windows 7
session_start();
$_SESSION['captcha'] = rand(1000, 9999);
require_once Yii::app()->request->baseUrl.'/images/captcha.php';
Any help will be appreciated.
Thanks in advance
joblo
(Joe)
June 8, 2014, 7:52am
2
And what’s the output of
var_dump(Yii::app()->request->baseUrl.'/images/captcha.php')
?
Keith
(Kburton)
June 8, 2014, 7:52am
3
require_once(Yii::getPathOfAlias('webroot.images') . '/captcha.php');
You need a file path, not a URL.
hoseng
(Shahsahebih)
June 8, 2014, 8:12am
4
Keith:
require_once(Yii::getPathOfAlias('webroot.images') . '/captcha.php');
You need a file path, not a URL.
Thanks Keith, and could you tell me how can I use this in img’s src attribute?
and also thanks Joblo
Keith
(Kburton)
June 8, 2014, 8:19am
5
Use the URL for that, the way you were getting it originally.
joblo
(Joe)
June 9, 2014, 6:01am
6
require_once 'images/captcha.php';
should work too, because the current working directory
var_dump(getcwd())
in Yii applications is always the directory of the index.php file.