You can try these two functions. :)
How to Display the Text contents of a text file in yii?
-
26-06-2023 - |
Question
I am trying to display the contents of a text file inside a div in my view. I found that in php
<?php
$myfilename = "mytextfile.txt";
if(file_exists($myfilename)){
echo file_get_contents($myfilename);
}
?>
this code can be used . Is there any such methods in Yii to display the contents inside a text file?
Update
This file is stored under components folder. It cannot be included inside the views section.
La solution
Autres conseils
There are renderFile()
method in CController class.
Put your text file somewhere at views/files and use that method like
$this->renderFile('/files/filename.txt');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow