No Such File Or Directory, But There Is!

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

And what’s the output of


var_dump(Yii::app()->request->baseUrl.'/images/captcha.php')

?




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

Use the URL for that, the way you were getting it originally.


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.