We can approach in two ways to get content from a file which is located in other server,
1) Using file function file_get_contents()
file_get_contents(< file URL >);
2) Using curl
For doing this by using curl, you need to add php curl library. If you are working on LAMP server, to install php curl, do as follows:
Open the terminal.
Run the command sudo apt-get install php5-curl
After execution restart your web server.
If you are on WAMP server, to install php curl library,
Open the php.ini file
Remove # in front of the php curl which you can found in extension/modules including section.
Restart your web server.
Before removing #, please ensure that the php_curl.dll file exists in installation path of WAMP server [Example – C:wampbinphpphp5.3.4ext]
Once you finished the installation of php curl library, use the code given below to get the file contents which is located in another server:
$link = '<URL>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);