Ipalaus\Geonames\Commands\ImportCommand::downloadFile PHP Метод

downloadFile() защищенный Метод

Download a file from a remote URL to a given path.
protected downloadFile ( string $url, string $path, $filename ) : void
$url string
$path string
Результат void
    protected function downloadFile($url, $path, $filename)
    {
        if (!($fp = fopen($path . '/' . $filename, 'w+'))) {
            throw new RuntimeException('Impossible to write to path: ' . $path);
        }
        // curl looks like shit but whatever
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
    }