DEV Community

Discussion on: PHP Tips: How to Read Remote Text File and Download to Local

Collapse
 
hepisec profile image
hepisec • Edited

You could also do it like this:

<?php
$src = file_get_contents('https://example.com/myfile.json');
file_put_contents('myfile.json', $src);

See
php.net/manual/en/function.file-ge...
php.net/manual/en/function.file-pu...

Collapse
 
sonyarianto profile image
Sony AK

Hi hepisec,
Thanks for the comments, nice addition, I will add it on the article :)