You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
707 B

6 years ago
<?php
/**
* Created by Error202
* Date: 13.09.2018
*/
namespace core\helpers;
class FileHelper extends \yii\helpers\FileHelper
{
3 years ago
public static function downloadFile($url, $path): bool
6 years ago
{
$new_file = null;
$new_name = $path;
$file = fopen($url, 'rb');
if ($file) {
$new_file = fopen($new_name, 'wb');
if ($new_file) {
while (!feof($file)) {
fwrite($new_file, fread($file, 1024 * 8), 1024 * 8);
}
}
}
if ($file) {
fclose($file);
}
if ($new_file) {
fclose($new_file);
}
3 years ago
return (bool)$new_file;
6 years ago
}
}