简体   繁体   English

如何通过php下载xml文件?

[英]How to download xml file through in php?

I created xml file in php. 我在php中创建了xml文件。 This file is successfully saved in my server directory. 此文件已成功保存在我的服务器目录中。
Now, I want to download this file only through php, not javascript. 现在,我只想通过php而不是javascript下载此文件。

How can I save this file? 如何保存该文件?

Try file_get_contents() and file_put_contents() . 尝试使用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.

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM