Help! In Yii, fopen cannot find the path. my code is written in the PHP file in view. the code is $ file_url = Yii: app ()-& gt; request-& gt; baseUrl. & quot;/file/"{file_name={file_url.'test.txt '; 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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.