You are here

function shrinktheweb_downloadRemoteImageToLocalPath in ShrinkTheWeb 8

Same name and namespace in other branches
  1. 6 shrinktheweb.api.inc \shrinktheweb_downloadRemoteImageToLocalPath()
  2. 7 shrinktheweb.api.inc \shrinktheweb_downloadRemoteImageToLocalPath()

Method to get image at the specified remote Url and attempt to save it to the specified local path.

Parameters

$sRemoteUrl:

$sFile:

Return value

bool

3 calls to shrinktheweb_downloadRemoteImageToLocalPath()
ShrinkTheWebCallbackController::receiveScreenshot in src/Controller/ShrinkTheWebCallbackController.php
shrinktheweb_getCachedThumbnail in ./shrinktheweb.api.inc
Get a thumbnail, caching it first if possible.
shrinktheweb_getNoResponseImage in ./shrinktheweb.api.inc
Gets the account problem image and returns the relative path to the cached image.

File

./shrinktheweb.api.inc, line 551

Code

function shrinktheweb_downloadRemoteImageToLocalPath($sRemoteUrl, $sFile) {
  $sRemoteData = shrinktheweb_fileGetContent($sRemoteUrl, array());

  // Only save data if we managed to get the file content.
  if ($sRemoteData) {
    $rFile = fopen($sFile, "w+");
    fputs($rFile, $sRemoteData);
    fclose($rFile);
  }
  else {

    // Try to delete file if download failed.
    if (file_exists($sFile)) {
      @unlink($sFile);
    }
    return FALSE;
  }
  return TRUE;
}