function _drush_download_file

8.0.x _drush_download_file($url, $destination, $overwrite = TRUE)
6.x _drush_download_file($url, $destination, $overwrite = TRUE)
7.x _drush_download_file($url, $destination, $overwrite = TRUE)
4.x _drush_download_file($url, $destination = FALSE, $overwrite = TRUE)
5.x _drush_download_file($url, $destination, $overwrite = TRUE)
master _drush_download_file($url, $destination, $overwrite = TRUE)

Download a file using wget, curl or file_get_contents. Does not use download cache.


string $url: The url of the file to download.

string $destination: The name of the file to be saved, which may include the full path.

boolean $overwrite: Overwrite any file thats already at the destination.

Return value

string The path to the downloaded file, or FALSE if the file could not be downloaded.

1 call to _drush_download_file()
drush_download_file in includes/
Download a file using wget, curl or file_get_contents, or via download cache.


includes/, line 836
The drush API implementation and helpers.


function _drush_download_file($url, $destination, $overwrite = TRUE) {
  static $use_wget;
  if ($use_wget === NULL) {
    $use_wget = drush_shell_exec('wget --version');

  $destination_tmp = drush_tempnam('download_file');
  if ($use_wget) {
    drush_shell_exec("wget -q --timeout=30 -O %s %s", $destination_tmp, $url);
  else {
    // Force TLS1+ as per
    drush_shell_exec("curl --tlsv1 --fail -s -L --connect-timeout 30 -o %s %s", $destination_tmp, $url);
  if (!drush_file_not_empty($destination_tmp) && $file = @file_get_contents($url)) {
    @file_put_contents($destination_tmp, $file);
  if (!drush_file_not_empty($destination_tmp)) {
    // Download failed.
    return FALSE;

  drush_move_dir($destination_tmp, $destination, $overwrite);
  return $destination;