You are here

function wget in Devel 5

Save contents of an url to filesystem. Works for images.

Return value

void

File

./devel.module, line 1524

Code

function wget($url, $file) {
  if (file_exists($file)) {
    return;
  }
  print "get: {$url}\n";
  $ch = curl_init($url);
  $fp = fopen($file, "w");
  curl_setopt($ch, CURLOPT_FILE, $fp);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_exec($ch);
  curl_close($ch);
  fclose($fp);
}