Shoutbox

[Solved]Download a file from an external server using PHP - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: [Solved]Download a file from an external server using PHP (/showthread.php?tid=62770)

[Solved]Download a file from an external server using PHP by Mike on 07-07-2006 at 08:39 PM

Hello..

I need to download an ASCII file from an external server to the server PHP is hosted, using PHP.

The reason I want to do this, is because I need to work with a file located in an external server.

I tried opening the file directly by passing the url as the file to open, but it said that allow_url_fopen is disabled.

I was suggested to use mod_socket to download the file, but it seems that mod_socket is disabled, because when I try to use socket_create; it says that I'm making a call to an undefined function...

So what can I do to download the file?

Thanks. :wavespam:


RE: Download a file from an external server using PHP by segosa on 07-07-2006 at 09:19 PM

code:
        function geturl($url)
        {
                $ch = curl_init();

                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);

                $out = curl_exec($ch);
                curl_close($ch);
                return $out;
        }


RE: Download a file from an external server using PHP by Mike on 07-07-2006 at 09:23 PM

Thanks segosa, working fine :)