!在Yii中使用fopen找不到路径

WBOY
Release: 2016-06-13 13:52:30
Original
911 people have browsed it

求助!在Yii中使用fopen找不到路径
我的代码写在view中php文件,
具体代码:
$file_url=Yii::app()->request->baseUrl."/file/";
$file_name=$file_url.'test.txt'; 
if($file=fopen($file_name, "w")){
 fwrite($file, '这是测试内容1');
 fclose($file);


显示错误:
fopen(/yiitest/file/test.txt) [function.fopen]: failed to open stream: No such file or directory

------解决方案--------------------
baseUrl 是网站的路径... fopen打开的是文件系统的路径的,不能混为一谈的.
------解决方案--------------------
路径加上域名就可以了
------解决方案--------------------

探讨

baseUrl 是网站的路径... fopen打开的是文件系统的路径的,不能混为一谈的.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template