! The path cannot be found using fopen in Yii

Source: Internet
Author: User
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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.