Skip to content

Commit

Permalink
Merge pull request #130 from jeroendesloovere/alternative-for-file_ge…
Browse files Browse the repository at this point in the history
…t_contents

Add fix for #75 and #79
  • Loading branch information
jeroendesloovere authored Jul 3, 2018
2 parents bc4226e + cc57d23 commit 89f203e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public function addRole($role)
* @param string $url image url or filename
* @param bool $include Do we include the image in our vcard or not?
* @param string $element The name of the element to set
* @throws VCardException
*/
private function addMedia($property, $url, $include = true, $element)
{
Expand Down Expand Up @@ -251,7 +252,15 @@ private function addMedia($property, $url, $include = true, $element)
$fileType = strtoupper(substr($mimeType, 6));

if ($include) {
$value = file_get_contents($url);
if ((bool) ini_get('allow_url_fopen') === true) {
$value = file_get_contents($url);
} else {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$value = curl_exec($curl);
curl_close($curl);
}

if (!$value) {
throw VCardException::emptyURL();
Expand Down

0 comments on commit 89f203e

Please sign in to comment.