Accessing file in the same directory

Hi all,

I have a view file in that image source is the file in same directory.  See the following syntax - 

<div class="simple">

<?php echo CHtml::image(‘graph.php’,‘testing graph’); ?>

</div>

File graph.php is in the same dir where above view file is placed. But its not getting the file graph.php. The path I am using is wrong. If I give whole path from <b>protected/view/site/graph.php<b> its giving an access denied error!

Does anybody know how to do this?

Thanks!

Your current directory will be the one where the index.php is. That’s why your first example didn’t work.

Contents of directory “protected” cannot be accessed directly(wich is ok, that’s why they are protected).

I think you should put a reference to a controller action in the images src attribute, and send the image from that action.

For example:

Controller:




class ImageController extends CController

{

...

  public function actionDisplay()

  {

    $this->render('/site/graph'); // render your graph

  }

...

}




View:




...

<?php echo CHtml::image(array('/image/display'),'testing graph'); ?>

...



Again thanks for the reply!

  I tried above, but doesn't seems to be working&#33;

What was the problem?