Help! In Yii, fopen cannot find the path. my code is written in the PHP file in view. the code is $ file_urlYii: Runtime; & nbsp; if ($ filefopen ($ file_name, & quot; help! The path cannot be found using fopen in Yii
My code is written in the PHP file in the view,
Code:
$ File_url = Yii: app ()-> request-> baseUrl. "/file /";
Using file_name1_1_file_url.'test.txt ';
If ($ file = fopen ($ file_name, "w ")){
Fwrite ($ file, 'This is test content 1 ');
Fclose ($ file );
}
Display error:
Fopen (/yiitest/file/test.txt) [function. fopen]: failed to open stream: No such file or directory
------ Solution --------------------
BaseUrl is the path of the website... fopen opens the path of the file system and cannot be confused.
------ Solution --------------------
Add the domain name to the path.
------ Solution --------------------
Discussion
BaseUrl is the path of the website... fopen opens the path of the file system and cannot be confused.