I know a few ways to this but none would work for all circumstances.
1.
Code: Select all
$file = 'http://somesite.com/example.txt';
$source = file_get_contents($file);
2.
Code: Select all
$file = 'http://somesite.com/example.txt';
system('wget ' .$file. ' > temp.txt');
$source = file_get_contents($temp.txt);
Code: Select all
$file = 'http://somesite.com/example.txt';
system('curl ' .$file. ' > temp.txt');
$source = file_get_contents($temp.txt);
3.
Code: Select all
$file = 'http://somesite.com/example.txt';
$ch = curl_init($file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$source = curl_exec($ch);
curl_close($ch);
I run out of ways. Any hints would be appreciated. Thanks!
--ngungo