Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #963 from gulaandrij/patch-1
Browse files Browse the repository at this point in the history
Update Image.php
  • Loading branch information
fzaninotto authored Sep 7, 2016
2 parents 493ad2a + b45ef03 commit 3e55d05
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Faker/Provider/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ public static function image($dir = null, $width = 640, $height = 480, $category
$fp = fopen($filepath, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$success = curl_exec($ch);
$success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;

if ($success) {
fclose($fp);
} else {
unlink($filepath);
}

curl_close($ch);
fclose($fp);
} elseif (ini_get('allow_url_fopen')) {
// use remote fopen() via copy()
$success = copy($url, $filepath);
Expand Down

0 comments on commit 3e55d05

Please sign in to comment.