Access protected directory from view

Hi,

I have a slight issue when trying to display a pdf file which has been created by yii which is stored within the protected directory, they are in that directory because they need to be emailed.

Can’t seem to get them to embed within a view, this is the code I am using:


<embed src="<?php echo Yii::app()->request->baseUrl; ?>/protected/pdf/path/to/thePdf.pdf" width="818" height="1057">

Thanks for any help.

The browser needs to have access to the file you are embedding… the protected folder (with all subfolders) is denied to the browser…

You should publish that pdf with CClientScript, thats the idea behind it, make things accessible, but i guess it depends on your business logic, you can also create a "pdfs" folder outside the protected folder and store those pdfs there.

Thanks, I thought that may be the case (the browser not having access)

Yup thats exactly what I ended up doing storing pdf’s outside protected directory works perfect now.

Thanks for the help guys :D