From 4fbfbd8ced705d7f72e3b824f50bbdd5ad649c13 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Mon, 20 Mar 2017 01:20:27 -0700 Subject: [PATCH] Use instance's file handle --- src/Curl/Curl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 7715362..8c61b11 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -304,7 +304,7 @@ class Curl { if (is_callable($mixed_filename)) { $this->downloadCompleteFunction = $mixed_filename; - $fh = tmpfile(); + $this->fileHandle = tmpfile(); } else { $filename = $mixed_filename; @@ -322,7 +322,7 @@ class Curl $range = $first_byte_position . '-'; $this->setOpt(CURLOPT_RANGE, $range); } - $fh = fopen($download_filename, $mode); + $this->fileHandle = fopen($download_filename, $mode); // Move the downloaded temporary file to the destination save path. $this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) { @@ -330,9 +330,8 @@ class Curl }; } - $this->setOpt(CURLOPT_FILE, $fh); + $this->setOpt(CURLOPT_FILE, $this->fileHandle); $this->get($url); - $this->downloadComplete($fh); return ! $this->error; }