+ -
当前位置:首页 → 问答吧 → 求助!在Yii中使用fopen找不到路径

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

时间:2011-03-26

来源:互联网

我的代码写在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) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory

作者: easunny2012   发布时间: 2011-03-26

baseUrl 是网站的路径... fopen打开的是文件系统的路径的,不能混为一谈的.

作者: jlzan1314   发布时间: 2011-03-26