How to save the file to your hosting on a link that is publicly available? Xml format

http://topnlab.ru/export/main/database/?data=objects&format=yandex&type=new&id=766344&key=XVWCFLzOZ9hrkJLItQ==

If you right-click on it and select "save link as ..." then it is downloaded (as a link on this site http://sro-gosst.ru/ ). How to make it so that you simply register the link and the document is uploaded to the hosting.

  • one
    I honestly do not understand. Especially did not understand what have yml . Download the file from the link and drop it on the ftp hosting. - teran
  • one
  • Well, if the task was this, I would have formulated it differently. As a result, the process will be automated. The catch is that I don `t know how to upload a file to the site code? - Victor Vasilyev
  • Where are you going to register the link? - br3t
  • In variable. At first I implemented this task through the function simplexml_load_file, but if the file turned out to be too large, for example, 500 MB each, then the server breaks the connection because I keep 502 errors for too long. So I thought that it was better to first upload the files to my server and then work with them, the question was how to do it if there is only a link to xml. - Victor Vasilyev

1 answer 1

If you do this in php, you can use the following code :

 <?php $file='http://topnlab.ru/export/main/database/?data=objects&format=yandex&type=new&id=766344&key=XVWCFLzOZ9hrkJLItQ=='; $host=__DIR__.'/new.xml'; copy($file, $host); chmod($host, 0777); 

Through copy works without problems, I checked. For automation, I recommend paying attention to how to delete the old file.

  • Everything works, for those who use this code, please pay attention to the permissions of the folder. - Victor Vasilyev