You can use this function, which creates a temporary file in the file system and returns the path to the downloaded file if everything works fine:
function getFileContents($url) { // Workaround: Save temp file $img = tempnam(sys_get_temp_dir(), 'pdf-'); $img .= '.' . pathinfo($url, PATHINFO_EXTENSION); $fp = fopen($img, 'w+'); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $result = curl_exec($ch); curl_close($ch); fclose($fp); return $result ? $img : false; }
Matthias Kleine Jun 22 '16 at 14:11 2016-06-22 14:11
source share