0

I'm using Yii Framework and I have custom .php file with header('Content-type: image/png'); Actually it returns an image.
I want in my view see that image this way:

<img src="path/to/custom/image.php"/>

Where should I put my custom php file? And how I should set it's path?

1
  • Why don't you put this code in a controller action ?? Commented Apr 23, 2013 at 12:31

1 Answer 1

2

Relative to your controller, example: ../../images/file.php, or you can do this:

<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/file.php"/>

In this way, the file must be accesible from outside.

Just to clarify, you shouldn't call this from your controller, but from your view.

Sign up to request clarification or add additional context in comments.

3 Comments

I think this way would be nice. Thx
If you are going to call it from a view and the image comes from a controller action you should use 'controller/action' url format using createUrl() from CController: yiiframework.com/doc/api/1.1/CController#createUrl-detail
yeap, I've edited my question, not from controller but from view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.