You are here

function shrinktheweb_downloadRemoteImageToLocalPath in ShrinkTheWeb 7

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

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

2 calls to shrinktheweb_downloadRemoteImageToLocalPath()
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 374

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;
}