如何通过php下载xml文件? [英] How to download xml file through in php?
本文介绍了如何通过php下载xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在php中创建了xml文件.此文件已成功保存在我的服务器目录中.
现在,我只想通过php而不是javascript下载此文件.
I created xml file in php. This file is successfully saved in my server directory.
Now, I want to download this file only through php, not javascript.
如何保存此文件?
推荐答案
尝试file_get_contents()
和file_put_contents()
.
<?PHP
$xml = file_get_contents("http://yoursite.com/yourxml.xml"); // your file is in the string "$xml" now.
file_put_contents("/path/to/file/yourxml.xml", $xml); // now your xml file is saved.
?>
这篇关于如何通过php下载xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文