PHP读写文件的错误!

公亮 公亮 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
temp.html和写文件的这个程序是在一个根目录下的,我运行下面的写文件操作程序,却提示出错!
Warning: fopen(temp.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 5

Warning: filesize() [function.filesize]: stat failed for temp.html in F:\test\8.php on line 6

Warning: fread(): supplied argument is not a valid stream resource in F:\test\8.php on line 6

Warning: fopen(test/test.html) [function.fopen]: failed to open stream: No such file or directory in F:\test\8.php on line 13
文件:test/test.html不可写,请检查其属性后重试!



这个是怎么回事情?明显的一个读失败,一个写失败!
请各位高手帮忙
下面是写文件操作的代码!

<?
$title = "拓迈国际测试模板";
$file = "TwoMax Inter test templet,author:_Max>Matrix@Two_Max";

$fp=fopen("temp.html","r");
$content = fread($fp,filesize ("temp.html"));
$content = str_replace ("{file}",$file,$content);
$content = str_replace ("{title}",$title,$content);


$filename = "test/test.html";
$handle = fopen ($filename,"w"); //打开文件指针,创建文件
/*
 检查文件是否被创建且可写
*/
if (!is_writable ($filename)){
die ("文件:".$filename."不可写,请检查其属性后重试!");
}
if (!fwrite ($handle,$content)){ //将信息写入文件
die ("生成文件".$filename."失败!");
}
fclose ($handle); //关闭指针

die ("创建文件".$filename."成功!");

?>
...全文
评论 15
收藏 已收藏
分享
返回顶部
公亮
基础编程 21,889 成员 140,329 内容