时时商务社区

标题: 如何使用PHP获取网络上文件 [打印本页]

作者: qz234    时间: 2018-2-14 09:46

            
Generating
[B]
Generating ...
Unable to load $srcurl. Static page ".
"update aborted!
");
exit();
}
//将这个URL的内容读入到一个PHP变量中。
//指定我们将读取1MB的数据(超过这个数据量一般是意味着出错了)。
$htmldata = fread($dynpage, 1024*1024);
//当我们完成工作后,关闭到源“文件”的连接。
fclose($dynpage);
//打开临时文件(同时在这个过程中建立)以用来写入(注意'w'的用法).
$tempfile = fopen($tempfilename, 'w');
//处理错误
if (!$tempfile) {
echo("Unable to open temporary file ".
"($tempfilename) for writing. Static page ".
"update aborted!
");
exit();
}
//将静态页面的数据写入到临时文件中
fwrite($tempfile, $htmldata);
//完成写入后,关闭临时文件。
fclose($tempfile);
//如果到了这里,我们应该已经成功地写好了一个临时文件,
//现在我们可以用它来覆盖原来的静态页面了。
$ok = copy($tempfilename, $targetfilename);
//最后删除这个临时文件。
unlink($tempfilename);
?>
Static page successfully updated!
[/B]
            
            
您可能感兴趣的文章:
  • 谈谈新手如何学习PHP网络编程
  • 使用php来实现网络服务
  • 使用PHP获取网络文件的实现代码
  • PHP 网络开发详解之远程文件包含漏洞
  • 使用php测试硬盘写入速度示例
  • PHP判断网络文件是否存在的方法
  • PHP网络操作函数汇总
  • PHP判断是否连接上网络的方法
  • PHP实现的简单网络硬盘
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2