简体   繁体   English

将XML文件从URL下载到cron服务器

[英]Download xml file from URL to server for cron

I've a problem, probably not so difficult most of you… Please help me 我有问题,也许你们大多数人都不那么困难……请帮助我

There is https://fakesite.com/example where is xml file. https://fakesite.com/example ,其中xml文件。 When I give this URL to explorer, asks what I would like do this file, where I want save etc. 当我将此URL提供给资源管理器时,询问我要对该文件进行什么操作,要将文件保存在何处等。

I need a small php script to my server, which is enable to download this xml file and save into my predefined server folder. 我需要一个小的php脚本到我的服务器,该脚本可以下载此xml文件并保存到我的预定义服务器文件夹中。 If the file (filename) already exist in my root folder, overwrite them. 如果该文件(文件名)已存在于我的根文件夹中,请覆盖它们。 The file name not important, would be original or anything with extension xml. 文件名不重要,可以是原始文件,也可以是带有xml扩展名的文件。 This php script should have run, when cron calls. 当cron调用时,此php脚本应该已经运行。

Any help would be appreciated…. 任何帮助,将不胜感激…。

Thanks in advance 提前致谢

  1. Use file_get_contents to download file contents. 使用file_get_contents下载文件内容。
  2. Create an output file name ie. 创建一个输出文件名,即。 using date ( date('Ymd-His') ) or a random string ( md5(date('now')) ) 使用日期( date('Ymd-His') )或随机字符串( md5(date('now'))
  3. Save data to the file using file_put_contents . 使用file_put_contents将数据保存到文件中。

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

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