30 lines
648 B
PHP
30 lines
648 B
PHP
|
<?php
|
||
|
|
||
|
namespace NAE\Functions\Curl;
|
||
|
|
||
|
/**
|
||
|
* Lädt eine Dei herunter mit Hilfe von php-curl.
|
||
|
* @param string Zielpfad
|
||
|
* @param string Quellpfad/URL
|
||
|
* @return bool Download Erfolgreich?
|
||
|
*/
|
||
|
function downloadFile(string $fileDestination, string $fileSource) : bool {
|
||
|
|
||
|
$ch = curl_init($fileSource);
|
||
|
|
||
|
$fp = fopen($fileDestination, 'wb');
|
||
|
|
||
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||
|
|
||
|
curl_exec($ch);
|
||
|
$info = curl_getinfo($ch);
|
||
|
|
||
|
curl_close($ch);
|
||
|
fclose($fp);
|
||
|
|
||
|
return ( $info["download_content_length"]==$info["size_download"] );
|
||
|
|
||
|
}
|